Hej, DECLARE @tmp TABLELista collation
Kan man skriva nått enkelt script som går igenom en databas och listar collation för alla textfält i alla tabeller?
Databasen jag är intresserad av är SQL Server 2005.
/JensSv: Lista collation
(
TableName VARCHAR(1000),
ColumnName VARCHAR(1000),
Collation VARCHAR(1000)
)
-- START LOOP
DECLARE cursor_name CURSOR
FOR
Select table_name from information_schema.tables where table_type='Base table' order by table_name
-- VARIABLE VALUES
DECLARE @TableName VARCHAR(1000)
OPEN cursor_name
FETCH NEXT FROM cursor_name INTO @TableName
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
INSERT INTO @tmp
SELECT obj.NAME, sys.name, collation
FROM syscolumns sys
JOIN sysobjects obj ON obj.NAME = @tablename
where sys.[id]=object_id(@tablename)
END
FETCH NEXT FROM cursor_name INTO @TableName
END
CLOSE cursor_name
DEALLOCATE cursor_name
-- STOP LOOP
SELECT *
FROM @tmp