SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Can this update be made easier
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

oracle765
Starting Member

Australia
13 Posts

Posted - 03/03/2013 :  22:14:53  Show Profile  Reply with Quote
I am running an update statement as follows
UPDATE dbo.BigTable
SET BigTable.Software_Version_Raw =
( CASE
WHEN dbo.BigTable.Software_Version_Raw LIKE '1.%' THEN '1.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '2.%' THEN '2.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '3.%' THEN '3.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '4.%' THEN '4.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '5.%' THEN '5.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '6.%' THEN '6.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '7.%' THEN '7.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '8.%' THEN '8.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '9.%' THEN '9.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '10.%' THEN '10.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '11.%' THEN '11.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '12.%' THEN '12.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '13.%' THEN '13.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '14.%' THEN '14.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '15.%' THEN '15.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '16.%' THEN '16.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '17.%' THEN '17.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '18.%' THEN '18.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '19.%' THEN '19.x'
WHEN dbo.BigTable.Software_Version_Raw LIKE '20.%' THEN '20.x'
WHEN dbo.BigTable.Software_Version_Raw = '1' THEN '1.x'
WHEN dbo.BigTable.Software_Version_Raw = '2' THEN '2.x'
WHEN dbo.BigTable.Software_Version_Raw = '3' THEN '3.x'
WHEN dbo.BigTable.Software_Version_Raw = '4' THEN '4.x'
WHEN dbo.BigTable.Software_Version_Raw = '5' THEN '5.x'
WHEN dbo.BigTable.Software_Version_Raw = '6' THEN '6.x'
WHEN dbo.BigTable.Software_Version_Raw = '7' THEN '7.x'
WHEN dbo.BigTable.Software_Version_Raw = '8' THEN '8.x'
WHEN dbo.BigTable.Software_Version_Raw = '9' THEN '9.x'
WHEN dbo.BigTable.Software_Version_Raw = '10' THEN '10.x'
WHEN dbo.BigTable.Software_Version_Raw = '11' THEN '11.x'
WHEN dbo.BigTable.Software_Version_Raw = '12' THEN '12.x'
WHEN dbo.BigTable.Software_Version_Raw = '13' THEN '13.x'
WHEN dbo.BigTable.Software_Version_Raw = '14' THEN '14.x'
WHEN dbo.BigTable.Software_Version_Raw = '15' THEN '15.x'
WHEN dbo.BigTable.Software_Version_Raw = '16' THEN '16.x'
WHEN dbo.BigTable.Software_Version_Raw = '17' THEN '17.x'
WHEN dbo.BigTable.Software_Version_Raw = '18' THEN '18.x'
WHEN dbo.BigTable.Software_Version_Raw = '19' THEN '19.x'
WHEN dbo.BigTable.Software_Version_Raw = '20' THEN '20.x'
ELSE dbo.BigTable.Software_Version_Raw
END
)

is there an easier way to do this EG search through the string and look for the full stop something like if it says
version 10.3.6.1 just search for the first full stop and make it say 10.x

any help would be appreciated

A Lynch

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 03/03/2013 :  22:35:34  Show Profile  Reply with Quote

UPDATE dbo.BigTable
SET BigTable.Software_Version_Raw = REPLACE(BigTable.Software_Version_Raw,'.%','') + '.x'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000