我已将postgresql数据库迁移到SQL Server 2016,其中我的所有文本列都具有TEXT
数据类型.我意识到TEXT
不应该在SQL Server中使用它.
是否有一个简单的查询来将所有文本列数据类型从SQL Server 更改TEXT
为VARCHAR(MAX)
?
我找到了这个答案但受列名限制.我想立刻做到这一切.
select
'alter table '||table_schema||'.'||table_name||' alter column'||column_name||' type text;'
from
information_schema.columns
where
table_schema = 'public'
and column_name = 'description'
and data_type = 'text';
Run Code Online (Sandbox Code Playgroud)