(SQL Server)SQL Server为多个表添加新的列
作者:互联网
sql如下:
/* * DECLARE:声明变量 * CONVERT:格式转换 详情查看 https://blog.csdn.net/lykangjia/article/details/51725768 */ DECLARE @Order CHARACTER(20) DECLARE @NUM INT DECLARE @sql CHARACTER(500) SET @NUM = 0 WHILE (@NUM < 51) BEGIN SET @Order = CONVERT(CHARACTER(10), @NUM) SET @sql = 'ALTER TABLE dbo.Chapter_'+ @Order +' ADD CpVolumeID varchar(36)' EXEC(@sql) SET @NUM = @NUM + 1 END
博客参考:
convert(varchar(10),字段名,转换格式):https://blog.csdn.net/lykangjia/article/details/51725768
SQL Server为多个表添加新的列:https://www.cnblogs.com/ywei221/p/3230621.html
标签:SET,sql,CHARACTER,Server,NUM,SQL,Order,添加,DECLARE 来源: https://www.cnblogs.com/hwh000/p/16180694.html