Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

SQL Problem

Thread Tools
 
Search this Thread
 
Old 28 January 2002, 11:18 AM
  #1  
The_Max STi
Scooby Regular
Thread Starter
 
The_Max STi's Avatar
 
Join Date: Apr 2001
Posts: 333
Likes: 0
Received 0 Likes on 0 Posts
Post

Hello

I don’t know if any one can help…

I need to strip the last 2 chars of a field in MS SQL

Say engine Size 1998CC I need to update that field to read 1998…

I hear you say just use left(enginesize,4) that’s great but what happens when the engine size is 900cc!!! Has any one got a suggestion to my problem?

Hope this makes sense to some one..!!!!

Thanks in advance
Rob
Old 28 January 2002, 11:28 AM
  #2  
AndrewW
Scooby Regular
 
AndrewW's Avatar
 
Join Date: Nov 2000
Location: Brisbane, Oz
Posts: 704
Likes: 0
Received 0 Likes on 0 Posts
Post

update table set field = substr(field, 1, length(field)-2)

where field is the name of the field you want to update.

May need to change the function names for substr and length to work in MS SQL, but this will work with oracle.

Andrew.

Old 28 January 2002, 11:36 AM
  #3  
The_Max STi
Scooby Regular
Thread Starter
 
The_Max STi's Avatar
 
Join Date: Apr 2001
Posts: 333
Likes: 0
Received 0 Likes on 0 Posts
Post

Geez that was Quick..

Ur a star Andrew... thanks..

update CarsUsed set enginesize = SUBSTRING(enginesize, 1, (len(enginesize)-2))

Weird how some commands are shortend in MS-SQL and some not..???

Thanks Again
Rob..
Old 28 January 2002, 11:44 AM
  #4  
AndrewW
Scooby Regular
 
AndrewW's Avatar
 
Join Date: Nov 2000
Location: Brisbane, Oz
Posts: 704
Likes: 0
Received 0 Likes on 0 Posts
Post

Yep,

That'd be micro$oft for you.

'If something works perfectly well and is an accepted standard, change it so that code written for m$ will not work on any other platform and vice versa'

Don't get me started on what they've tried to do to Java [img]images/smilies/mad.gif[/img]

Glad I could help.

Andrew.


[Edited by AndrewW - 1/28/2002 11:45:12 AM]
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Abx
Subaru
22
09 January 2016 05:42 PM
PetrolHeadKid
Driving Dynamics
10
05 October 2015 05:19 PM
T.K
General Technical
10
02 October 2015 11:35 AM
the shreksta
Other Marques
26
01 October 2015 02:30 PM
minguela
Wheels And Tyres For Sale
0
29 September 2015 11:28 AM



Quick Reply: SQL Problem



All times are GMT +1. The time now is 01:49 AM.