Tag Info

New answers tagged

7

DECLARE @sql NVARCHAR(MAX) = N''; SELECT @sql += [sql] FROM ( SELECT [sql] = N' ALTER TABLE ' + QUOTENAME(s.name) + '.' + QUOTENAME(t.name) + ' ALTER COLUMN ' + c.name + ' VARCHAR(50);' FROM sys.columns AS c INNER JOIN sys.tables AS t ON c.[object_id] = t.[object_id] INNER JOIN sys.schemas AS s ON t.[schema_id] = s.[schema_id] WHERE ...


6

Here is a query that does a few things: use YourDatabase; go select object_name = object_name(c.object_id), column_name = c.name, type_name = t.name, c.max_length, alter_table_ddl = 'alter table ' + quotename(object_schema_name(c.object_id)) + '.' + quotename(object_name(c.object_id)) + ' ...



Top 50 recent answers are included