select T.NAME,'ALTER TABLE [dbo].['+t.name+ '] ALTER COLUMN ' + c.name + ' NVARCHAR('+CAST(C.max_length AS NVARCHAR )+ ')',
c.name ,
tp.name,
c.max_length
From sys.tables t inner join sys.all_columns c on c.object_id = t.object_id
inner join sys.types tp on tp.system_type_id = c.system_type_id
where tp.name = 'varchar' -- nvarchar , int , bigint
--and c.max_length = -1 -- length of the data type is -1 implying that its VARCHAR (MAX) LOB
ORDER BY T.NAME
is this only a query ?
ReplyDeleteThe query should also put a GO under it
ReplyDelete