SQL Server 2008的常用高级脚本



(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';

posted on 2014-03-12 16:02  omage  阅读(48)  评论(0编辑  收藏  举报