ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   SQL Problem (https://www.scoobynet.com/computer-and-technology-related-34/68147-sql-problem.html)

The_Max STi 28 January 2002 11:18 AM

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

AndrewW 28 January 2002 11:28 AM

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.


The_Max STi 28 January 2002 11:36 AM

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..

AndrewW 28 January 2002 11:44 AM

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]


All times are GMT +1. The time now is 09:37 PM.


© 2024 MH Sub I, LLC dba Internet Brands