I faced a probem with a join on 2 database.
After digging for a while i found that one of my database
COLLATION was SQL_Latin1_General_CP1_CI_AS and Second was Latin1_General_CI_AI
Collation Related Error are based on Sql Server Setup or a database Restore from some external server.
As you know database can directly be restored in Sql Server 2005 without "Create new Database" and then "Restore"
Sql Server 2005
option 1. 'Latin1_General_CI_AI' (Fresh Setup on OS having no Instance of SQL Server)
option 2. 'SQL_Latin1_General_CP1_CI_AS' (Compatibility with previous versions of Sql Server.)
Query to Check for Collation
--> First Select your Database and then try this Query
PRINT 'MY DATABASE [' + DB_NAME() + '] COLLATION IS: ' + CAST( DATABASEPROPERTYEX ( DB_NAME(), N'COLLATION' ) AS VARCHAR(128) ) PRINT 'MY TEMPDB DATABASE COLLATION IS: ' + CAST( DATABASEPROPERTYEX ( 'TEMPDB', N'COLLATION' ) AS VARCHAR(128) )
Query to Change collation of A Database
ALTER DATABASE yourDBName COLLATE Latin1_General_CI_AI or SQL_Latin1_General_CP1_CI_AS or the one you need
Query all the Databases for Collation & compatibility level
SELECT NAME, COLLATION_NAME, COMPATIBILITY_LEVEL, * FROM SYS.DATABASES
SELECT SERVERPROPERTY('COLLATION')
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment