遍曆資料庫所有表,將是datetime類型的列的值進行更新,資料庫datetime

來源:互聯網
上載者:User

遍曆資料庫所有表,將是datetime類型的列的值進行更新,資料庫datetime
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

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.