USE BookDiscuss DECLARE @num INT DECLARE @numdiff INT DECLARE @table VARCHAR(50) DECLARE @sql VARCHAR(8000) SET @numdiff=3 SET @num=0 WHILE @num<@numdiff BEGIN SET @table='DiscussPost_'+CAST(@num AS VARCHAR(10)); SET @sql= 'ALTER TABLE '+@table+' ADD PostFatherId INT DEFAULT 0; ALTER TABLE '+@table+' ADD PostReplyUserId INT DEFAULT 0;' EXEC(@sql) SET @num=@num+1 END