--循环在表中增加列
SET NOCOUNT ON
DECLARE @barcode_head varchar(10)
declare @sql varchar(500)
--声明游标
DECLARE business_cursor CURSOR FOR
SELECT barcode_head FROM s_business order by id
OPEN business_cursor
FETCH NEXT FROM business_cursor INTO @barcode_head
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @barcode_head
set @sql='alter table db_'+@barcode_head+'_user add Trans_startTime datetime'
exec(@sql)
print @sql
FETCH NEXT FROM business_cursor INTO @barcode_head
end
close business_cursor
DEALLOCATE business_cursor
GO