Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Can this update be made easier

Author  Topic 

oracle765
Starting Member

13 Posts

Posted - 2013-03-03 : 22:14:53
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

52326 Posts

Posted - 2013-03-03 : 22:35:34
[code]
UPDATE dbo.BigTable
SET BigTable.Software_Version_Raw = REPLACE(BigTable.Software_Version_Raw,'.%','') + '.x'
[/code]

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

Go to Top of Page
   

- Advertisement -