22,207
社区成员
发帖
与我相关
我的任务
分享
sp_MSforeachtable @command1 = "alter TABLE ? ADD col1 varchar(50) NULL"
declare @sql varchar(max)
select @sql = isnull(@sql,'')+' alter table dbo.'+[name]+' add col1 varchar(50) null '
from sys.objects
where [type] = 'U'
print @sql
exec(@sql)