SQL Server Performance

TSQL to generate a script that updates a column on every table in my database. How do I do this?

Discussion in 'Other SQL Server Blogs around the Web' started by Anonymous, Jul 29, 2007.

  1. Anonymous New Member

    SELECT 'ALTER TABLE ' + sysobjects.name + ' ' + 'ALTER COLUMN ' + syscolumns.name + ' ' + systypes.name + '(' + cast(syscolumns.length as varchar) + ') ' + 'COLLATE ' + syscolumns.collation + ' ' + case when syscolumns.isnullable = 1 then 'NULL' else 'NOT NULL' end sql from syscolumns inner join sysobjects on sysobjects.id = syscolumns.id inner join systypes on systypes.xtype = syscolumns.xtype where syscolumns.collation is not null This is useful when you need to change the collation for the columns...(<a href="http://sqlserver-qa.net/blogs/t-sql/archive/2007/07/29/1180.aspx">read more</a>)<img src="http://sqlserver-qa.net/aggbug.aspx?PostID=1180" width="1" height="1">

Share This Page