-- VERIFICANDO COLLACTION DAS TABELAS-- CHECKING COLLATION OF TABLESSELECTa.name as'NomeTabela' ,b.name as'NomeColuna',b.collation ,c.name as'TipoDados',b.length as'Tamanho'FROM sysobjects Ainner join syscolumns B on a.id = b.idinner join sys.types C on C.system_type_id = b.xtypeWHERE a.xType = 'U'and b.collation is not nulland ((c.name = 'char') or (c.name = 'varchar'))and a.name in (SELECT table_name FROM information_schema.tables)order by a.name;-- SQL SERVER 2000-- VERIFICAR COLLATION DE UMA OU TODAS AS TABELAS-- CHECK COLLATION OF ONE OR ALL TABLESSELECTa.name as'NomeTabela' ,b.name as'NomeColuna',b.collation ,c.name as'TipoDados',b.length as'Tamanho'FROM sysobjects Ainner join syscolumns B on a.id = b.idinner join systypes C on C.xtype = b.xtypeWHERE a.xType = 'U'and b.collation is not nulland ((c.name = 'char') or (c.name = 'varchar'))and a.name in (SELECT table_name FROM information_schema.tables)AND a.name LIKE't'– FILTRO NOME DA TABELAorder by a.name-- VERIFICAR COLLATION DE UMA OU TODAS AS TABELAS-- CHECK COLLATION OF ONE OR ALL TABLESSELECTa.name as'NomeTabela' ,b.name as'NomeColuna',b.collation ,c.name as'TipoDados',b.length as'Tamanho'FROM sysobjects Ainner join syscolumns B on a.id = b.idinner join systypes C on C.xtype = b.xtypeWHERE a.xType = 'U'and b.collation is not nulland ((c.name = 'char') or (c.name = 'varchar'))and a.name in (SELECT table_name FROM information_schema.tables)AND a.name LIKE't'– FILTROorder by a.name-- ALTERARDECLARE @tabela VARCHAR(100)DECLARE @collate VARCHAR(100)–SET @tabela='t'SET @collate='SQL_Latin1_General_CP1_CI_AI' — SQL_Latin1_General_CP1_CI_AISELECT'Alter Table '+ a.name + ' Alter Column '+ b.name +' '+c.name +' ('+CONVERT(VARCHAR(50),b.length)+') Collate'+' '+@collateFROM sysobjects Ainner join syscolumns B on a.id = b.idinner join systypes C on C.xtype = b.xtypeWHERE a.xType = 'U'and b.collation is not nulland ((c.name = 'char') or (c.name = 'varchar'))and a.name in (SELECT table_name FROM information_schema.tables)and b.collation notlike'SQL_Latin1_General_CP1_CI_AI'--AND a.name=@tabela — FILTROorder by a.name-- COMPROVANDO QUE NÃO EXISTEM TABELAS COM COLLATION DIFERENTE DO SOLICITADO -- PROVING THAT THERE ARE NO TABLES WITH A COLLATION DIFFERENT FROM THE REQUESTEDSELECTa.name as'NomeTabela' ,b.name as'NomeColuna',b.collation ,c.name as'TipoDados',b.length as'Tamanho'FROM sysobjects Ainner join syscolumns B on a.id = b.idinner join sys.types C on C.system_type_id = b.xtypeWHERE a.xType = 'U'and b.collation is not nulland ((c.name = 'char') or (c.name = 'varchar'))and a.name in (SELECT table_name FROM information_schema.tables)and b.collation !='SQL_Latin1_General_CP1_CI_AI'order by a.name