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 Jan 28, 2002 | 11:18 AM
  #1  
The_Max STi's Avatar
The_Max STi
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 333
Likes: 0
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
Reply
Old Jan 28, 2002 | 11:28 AM
  #2  
AndrewW's Avatar
AndrewW
Scooby Regular
 
Joined: Nov 2000
Posts: 704
Likes: 0
From: Brisbane, Oz
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.

Reply
Old Jan 28, 2002 | 11:36 AM
  #3  
The_Max STi's Avatar
The_Max STi
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 333
Likes: 0
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..
Reply
Old Jan 28, 2002 | 11:44 AM
  #4  
AndrewW's Avatar
AndrewW
Scooby Regular
 
Joined: Nov 2000
Posts: 704
Likes: 0
From: Brisbane, Oz
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]
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Abx
Subaru
22
Jan 9, 2016 05:42 PM
PetrolHeadKid
Driving Dynamics
10
Oct 5, 2015 05:19 PM
T.K
General Technical
10
Oct 2, 2015 11:35 AM
the shreksta
Other Marques
26
Oct 1, 2015 02:30 PM
minguela
Wheels And Tyres For Sale
0
Sep 29, 2015 11:28 AM




All times are GMT +1. The time now is 10:46 AM.