|
|
|
SSC-Dedicated
           
Group: Administrators
Last Login: 2 days ago @ 1:47 PM
Points: 31,406,
Visits: 13,722
|
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, October 30, 2012 10:37 AM
Points: 263,
Visits: 859
|
|
"Most DBAs don't ever deal with multiple languages or different collation and sort order settings in SQL Server"
Now there's a sweeping statement. In fact, I would say many (if not all) non-USA DBA's have had to deal with this. Convert to SQL_Latin1_General_CP1_CI_AS or die, Latin1_General_CI_AS scum!
James Stover, McDBA
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Thursday, May 02, 2013 1:12 AM
Points: 1,584,
Visits: 379
|
|
I've come across this one quite a bit at one contract I had as a third-party vendor insisted that the performance of a binary collation was much quicker than a case-insensitive one and so set the default to Latin1_General_Bin for everything.
I'm not sure if there are tests/stats to back this claim up but I do know that the majority of queries against the data were name related and so most of their queries were written as UPPER([NameColumn]) = UPPER(@Criteria). Brilliant !! Index seek to index scan in one easy step.
After seeing this I wasn't inclined to believe their performance enhancement claim.
Dan www.firstcs.co.uk
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, May 13, 2013 4:59 AM
Points: 163,
Visits: 283
|
|
Good practice is to use same collation whenever it's possible. If you have databases with different collations on the same sever use COLLATION database_default in CREATE/ALTER TABLE statement to not confuse yourself. When import objects from other sources check collation of destination tables.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, June 07, 2012 1:36 AM
Points: 5,
Visits: 26
|
|
Hello Steve!
I've nearly the same problem with collation. I've had to build a "data warehouse" from four different different databases of four systems, one of them is multilingual.
The solution slightly differs only:
SELECT ...............
FROM [DB1].[dbo].[TABLE1] as T1
inner join [DB2].[dbo].[TABLE2] as T2
on T1.name SQL_Latin1_General_CP1_CI_AS
= T2.table_name SQL_Latin1_General_CP1_CI_AS
In this case both sides of join are forced to use the same collation 
I hadn't time to check the theoretical fundamentals or efficiency aspects, but in practice it's works.
Best regards: Richard
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: 2 days ago @ 4:52 AM
Points: 1,397,
Visits: 2,738
|
|
"Most DBAs don't ever deal with multiple languages or different collation and sort order settings in SQL Server"
The majority of UK DBA's will have come across collation issues, its a common problem for me. I currently have a server having 9 databases with various different collations at table and row level and am trying to clean up the mess.... To identify whether I had issues:-
USE MASTER
GO
SET NOCOUNT ON
DECLARE @DB VARCHAR (150),
@Counter INT,
@Rec VARCHAR (150),
@SQL VARCHAR (1000),
@SQL1 VARCHAR (1000),
@SQL2VARCHAR (1000)
SELECT database_id, name INTO #Temp
FROM sys.databases
WHERE name NOT IN ('Master', 'tempdb','msdb','model')
SET @Counter = (SELECT MIN(database_id) FROM #Temp)
/*Work out if a database has more than one collation, assumes only interested if more than one*/
CREATE TABLE #ctr
( NumRows int )
WHILE @Counter <= (SELECT MAX(database_id) FROM #Temp)
BEGIN
SET @DB = (SELECT name
FROM #Temp
WHERE database_id = @Counter)
--Alter 'Latin' below if not just comparing US/UK
SET @SQL = 'INSERT INTO #ctr SELECT count(distinct COLLATION_NAME)
FROM '+ @DB +'.INFORMATION_SCHEMA.columns
WHERE COLLATION_NAME LIKE ''%Latin%'' '
EXEC (@SQL)
SET @Rec = (SELECT NumRows FROM #ctr)
DELETE FROM #ctr
IF (@Rec > 1)
BEGIN
PRINT @DB
SET @SQL1 = 'SELECT TABLE_CATALOG AS [DATABASE], '
SET @SQL1 = @SQL1 +'TABLE_NAME, '
SET @SQL1 = @SQL1 +'COLLATION_NAME, '
SET @SQL1 = @SQL1 +'COLUMN_NAME, '
SET @SQL1 = @SQL1 +'DATA_TYPE '
SET @SQL1 = @SQL1 +'FROM '+ @DB +'.INFORMATION_SCHEMA.columns '
SET @SQL1 = @SQL1 +'WHERE TABLE_NAME <> ''dtproperties'' '
SET @SQL1 = @SQL1 +'AND COLLATION_NAME LIKE ''%Latin%'' '
SET @SQL1 = @SQL1 +'ORDER BY COLUMN_NAME'
EXEC (@SQL1)
END
SET @Counter = @Counter + 1
END
DROP TABLE #ctr
GO
DROP TABLE #Temp
GO
Facts are stubborn things, but statistics are more pliable - Mark Twain Carolyn SQLServerSpecialists
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Thursday, May 09, 2013 8:17 AM
Points: 82,
Visits: 61
|
|
Hi, we've had similar problems with collations across different data sources, but have also found one bonus. As part of the validation for data imports we check for personal info being in upper case by using a case sensitive collation
--Does the data need to be proper cased
select 'Employee- ' +d.EMP_REF+ ' name- ' +d.SURNAME
from DOWNLOAD_Employee d
where substring(d.SURNAME, 2, 1) --get second character in SURNAME
<> lower(substring(d.SURNAME, 2, 1)) --get second character again and lowercase it
collate sql_latin1_general_cp1_cs_as --compare the two using a case-sensitive collation
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, February 06, 2013 10:43 AM
Points: 3,
Visits: 205
|
|
Steve, nice article and a nice pointer ref to Tony Rogerson. I ran in to this issue also here in the UK after I restored a DB built on a UK locale server to a US locale-built server which itself had DBs created using default US-locale led collation. Tony's article help me fix the resultant mixed-collation issues (as I wanted to union results from several source DBs with differing collations).
Anyway one addition I wanted to mention was watch the collation on your Tempdb aswell as your User DBs, as it can affect your query results in a mixed collation DB environment. Here's a couple URLs:
Kimberley Tripp article titled 'Changing Database Collation and dealing with TempDB Objects'
@ http://www.sqlskills.com/blogs/kimberly/PermaLink.aspx?guid=7b4c9796-66d0-4ed2-b19d-bef6bb1e3e1d#a7b4c9796-66d0-4ed2-b19d-bef6bb1e3e1d
Michael Kaplan's blog entry @ http://blogs.msdn.com/michkap/archive/2006/05/30/610889.aspx
Hope this helps.
Cheers, Neil (DBA in UK)
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Monday, January 21, 2013 2:19 AM
Points: 572,
Visits: 310
|
|
This problem is excaserbated by 'part-time' DBAs in the UK blindly installing SQL Server with defualts without referring to the regional settings of the server which influence the default collation of the sql server. The UK default is the Windows collation introduced with SQL 2000 which according to microsoft gives performance benifits as it matches that of the OS. I have no idea why the US defaults to a collation that was supposed to be only there for backwards compatability.
|
|
|
|
|
SSC-Dedicated
           
Group: Administrators
Last Login: 2 days ago @ 1:47 PM
Points: 31,406,
Visits: 13,722
|
|
|
|
|