日期:2014-05-17 浏览次数:20453 次
select 'alter table '+ a.name+ ' alter column ['+b.name+'] nvarchar(max)'
from sysobjects a
left join syscolumns b on a.id=b.id
left join systypes c on b.xtype=c.xtype
where a.xtype='U' and c.name='nvarchar'
SELECT 'alter table '+OBJECT_NAME(OBJECT_ID)+' alter column '+a.name+' '+b.name+'('+CASE WHEN a.max_length=-1 THEN 'max' ELSE CONVERT(NVARCHAR(10),a.max_length) END+')'+' Collate SQL_Latin1_General_CP1_CI_AS'
FROM sys.columns a INNER JOIN sys.types b ON a.system_type_id=b.system_type_id
WHERE OBJECT_NAME(OBJECT_ID) NOT LIKE 'sys%' AND a.collation_name IS NOT NULL AND a.collation_name <>'SQL_Latin1_General_CP1_CI_AS' AND a.system_type_id IN (167,231,239)