[SQL Server] can this update statement be made easier |
can this update statement be made easier Posted: 03 Mar 2013 11:55 AM PST I am running an update statement as followsUPDATE dbo.BigTableSET 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 saysversion 10.3.6.1 just search for the first full stop and make it say 10.xany help would be appreciated |
Posted: 03 Mar 2013 01:47 AM PST Hi,Please see below, Table name : Log_tableColumns: Logid int, databasename varchar(30), tablename varchar(30), logdate datetimeQuery 1: Select max(logdate) from log_table where databasename='db1' and tablename='table1';consider the Log_table is empty, when I execute Query 1, the result will be 'Null'.Query 2 : select max(logdate) from log_table Where databasename='db1' and tablename='table1' group by databasename,tablename;Consider the log_table is empty, when I execute Query 2, the result will be empty.Note : both the condition table is empty.Please explain me what happening inside and why the result different? |
You are subscribed to email updates from SQLServerCentral / SQL Server 2008 / SQL Server Newbies To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment