SQL Problem
#1
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
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
#2
Scooby Regular
Join Date: Nov 2000
Location: Brisbane, Oz
Posts: 704
Likes: 0
Received 0 Likes
on
0 Posts
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.
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.
#3
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..
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..
#4
Scooby Regular
Join Date: Nov 2000
Location: Brisbane, Oz
Posts: 704
Likes: 0
Received 0 Likes
on
0 Posts
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]
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]
Thread
Thread Starter
Forum
Replies
Last Post