SQL 批量修改表结构

  项目中发现一批语言表的某个字段设的值太小了需要增大,因为涉及到很多张表,所以采用游标一张张的处理。

代码很简单

DECLARE @tableName NVARCHAR(50)
DECLARE @sql NVARCHAR(200) DECLARE LangTable CURSOR FOR
SELECT name FROM sys.tables WHERE name LIKE '%Language' OPEN LangTable
FETCH NEXT FROM LangTable INTO @tableName WHILE @@FETCH_STATUS = 0
BEGIN SET @sql = 'ALTER TABLE '+@tableName+' ALTER COLUMN LanguageDesc NVARCHAR(MAX)'
EXEC @sql FETCH NEXT FROM LangTable INTO @tableName END CLOSE LangTable
DEALLOCATE LangTable
上一篇:泛函p121可分Hilbert空间都同构于l^2


下一篇:JMS学习篇《一》ActiveMQ消息中间件的简单介绍与用法-概念篇