Código SQL:
Ver original
--Primero insertamos los nombres de las tablas que queremos actualizar SELECT TABLE_NAME, IDENTITY(INT, 1,1) AS ROW INTO #temp FROM information_schema.TABLES WHERE table_schema LIKE '%dbo%' AND table_type LIKE '%base%' DECLARE @x INT DECLARE @total INT DECLARE @query VARCHAR(MAX) DECLARE @TABLE_NAME VARCHAR(200) DECLARE @column_name VARCHAR(200) DECLARE @datos INT DECLARE @y INT DECLARE @total2 INT SELECT @total=COUNT(*) FROM #temp SET @x=1 while @x<=@total BEGIN --obtenemos el nombre de la tabla SELECT @TABLE_NAME=TABLE_NAME FROM #temp WHERE ROW=@x --y buscamos en cada columna de esa tabla el tipo de dato que nos interesa SET @query='select column_name, table_name,identity(int, 1,1) as row into ##temp2 from information_schema.columns where table_name like ' + CHAR(39) + '%' +@TABLE_NAME + '%' + CHAR(39) +' and data_type like ' + CHAR(39) + '%date%' + CHAR(39) EXEC Sp_sqlExec @query SELECT @datos=COUNT(*) FROM ##temp2 IF @datos>=1 BEGIN SELECT @total2=COUNT(*) FROM ##temp2 SET @y=1 while @y<=@total2 BEGIN SELECT @column_name=column_name FROM ##temp2 WHERE ROW=@y --ya con el nombre hacemos el update a la tabla en este caso por una fecha en formato UTC SET @query='update ' + @TABLE_NAME + ' set '+ @column_name + '=getutcdate()' EXEC Sp_sqlExec @query print @column_name SET @y=@y+1 END SELECT @TABLE_NAME=TABLE_NAME FROM ##temp2 print @TABLE_NAME END DROP TABLE ##temp2 SET @x=@x+1 END
Saludos!!