SQL Server 2008的常用高级脚本

时间:2022-06-10 00:55:10


(1) 每个表全部加上一个字段

EXEC sp_MSforeachtable '
if not exists (select * from sys.columns
               where object_id = object_id(''?'')
               and name = ''Server'')
begin
    ALTER TABLE ? ADD [Server] [nvarchar](max) COLLATE Chinese_PRC_CI_AS NULL
end';