The table contains no indices.The script I'm using was kindly provided by jhocutt, from this forum, who responded to a previous thread I started regarding iterating through columns:DECLARE @tbl varchar(1000), @col varchar(1000), @sql nvarchar(4000)DECLARE Cur1 CURSOR FAST_FORWARD FORSELECT o.name tbl , c.name colFROM sysobjects o INNER JOIN syscolumns c ON o.id = c.idWHERE o.name = 'business_table'---- replace o.name = '....' with o.xtype='U' for ALL tables in database -------AND lower(c.name) like '%date%'OPEN Cur1FETCH NEXT FROM Cur1 INTO @tbl, @colWHILE @@fetch_status = 0BEGINSET @sql = 'UPDATE dbo.' + @tbl + 'SET ' + QUOTENAME(@col) + ' = CASEWHEN ' + QUOTENAME(@col) + ' = ''0'' THEN NULLWHEN ' + QUOTENAME(@col) + ' LIKE ''10%'' THEN ''20'' + SUBSTRING(' + QUOTENAME(@col) + ', 2, LEN(' + QUOTENAME(@col) + '))ELSE ''19'' + ' + QUOTENAME(@col) + 'ENDALTER TABLE dbo.' + @tbl + ' ALTER COLUMN ' + QUOTENAME{@col) + ' datetime IS NULL'PRINT @sqlEXECUTE sp_executesql @sql --UNCOMMENT TO ACTUALLY RUNFETCH NEXT FROM Cur1 INTO @tbl, @colENDCLOSE Cur1DEALLOCATE Cur1
I also tried to get the script to change the column type to datetime once it had performed the re-formatting of the data (if any), but without success so far. Not sure why just now.