遍历数据库全部表,将是datetime类型的列的值进行更新
时间:2021-07-01 10:21:17
帮助过:27人阅读
declare @tablename nvarchar(80)
declare @cloumn nvarchar(80)
declare @sql nvarchar(400)
declare c1 cursor scroll for
select table_name,column_name from information_schema.columns where DATA_TYPE=‘datetime‘
open c1
fetch first from c1 into @tablename,@cloumn
while @@fetch_status=0
begin
set @sql=‘update ‘+@tablename+‘ set
‘+@cloumn+‘=DATEADD(yy,10,‘+@cloumn+‘) where
‘+@cloumn+‘ is not null‘;
exec (@sql)
fetch next from c1 into @tablename,@cloumn
end
close c1
遍历数据库全部表,将是datetime类型的列的值进行更新
标签:content form nbsp select har post int char var