To alter all columns of a table :
DECLARE
@SQL VARCHAR(MAX)
SET @SQL
= (
SELECT '
ALTER TABLE dbo.yourtablename ALTER COLUMN ['
+ c.name
+ ']
NVARCHAR(MAX) NULL;
'
FROM sys.columns
c WHERE OBJECT_NAME(object_id)
= 'yourtablename'
FOR XML
PATH(''),
TYPE
).value('text()[1]',
'VARCHAR(MAX)')
--PRINT @SQL
EXEC(@SQL)
No comments:
Post a Comment