Altering Multiple Tables at once
问题 I'm trying to alter multiple SQL Server 2008 R2 tables at one time. This is my code: use DatabaseName go Declare @SchemaUsed varchar(20) = 'dbo' create table #Tables ( TableName varchar(100), Processed int ) insert into #Tables select top 1 table_name, 0 from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = @SchemaUsed and table_type = 'Base Table' and (TABLE_NAME like 'PM%' ) ORDER BY TABLE_NAME DECLARE @TableName varchar(max) DECLARE @SQL varchar(max) WHILE EXISTS (select top 1 'x' from