SQLUSA.com
SQL SERVER 2008 GRAND SLAM
FREE TRIAL  CLICK HERE TO ORDER  SEARCH
SQL JOBS SQL Server Training Scripts JOB BANK
  SQL Server 2008 Training Scripts  
  SQL Server 2005 Training Scripts  
News SQL Server Articles SQL Format

How to work around error 468?

Execute the following Microsoft SQL Server Transact-SQL (T-SQL) script in Management Studio (SSMS) Query Editor, SQLCMD or other client software to create a collation conflict between two EmailAddresses: one is CI case insensitive, the other is CS case sensitive. The first SELECT JOIN without the "COLLATE" gives error 468. All the SELECT JOINs with "COLLATE" will work.

USE tempdb
GO

CREATE TABLE [dbo].[Contact](
[ContactID] [int] NOT NULL,
[NameStyle] [int] NOT NULL CONSTRAINT [DF_Contact_NameStyle] DEFAULT ((0)),
[Title] [nvarchar](8) NULL,
[FirstName] [nvarchar](50) NOT NULL,
[MiddleName] [nvarchar](50) NULL,
[LastName] [nvarchar](50) NOT NULL,
[Suffix] [nvarchar](10) NULL,
[EmailAddress] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CS_AS NULL,
[EmailPromotion] [int] NOT NULL CONSTRAINT [DF_Contact_EmailPromotion] DEFAULT ((0)),
[Phone] [nvarchar](25) NULL,
[PasswordHash] [varchar](40) NOT NULL,
[PasswordSalt] [varchar](10) NOT NULL,
[AdditionalContactInfo] [xml] NULL,
[rowguid] [uniqueidentifier] ROWGUIDCOL NOT NULL CONSTRAINT [DF_Contact_rowguid] DEFAULT (newid()),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_Contact_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_Contact_ContactID] PRIMARY KEY CLUSTERED
(
[ContactID] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

INSERT dbo.Contact
SELECT * from AdventureWorks.Person.Contact
GO

SELECT a.*
FROM AdventureWorks.Person.Contact a
JOIN dbo.Contact b
ON a.EmailAddress = b.EmailAddress
GO

/*

Msg 468, Level 16, State 9, Line 1
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CS_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

*/

-- All below will work

SELECT a.*
FROM AdventureWorks.Person.Contact a
JOIN dbo.Contact b
ON a.EmailAddress = b.EmailAddress COLLATE DATABASE_DEFAULT
GO

SELECT a.*
FROM AdventureWorks.Person.Contact a
JOIN dbo.Contact b
ON a.EmailAddress COLLATE DATABASE_DEFAULT = b.EmailAddress
GO

SELECT a.*
FROM AdventureWorks.Person.Contact a
JOIN dbo.Contact b
ON a.EmailAddress COLLATE SQL_Latin1_General_CP1_CS_AS = b.EmailAddress
GO

SELECT a.*
FROM AdventureWorks.Person.Contact a
JOIN dbo.Contact b
ON a.EmailAddress = b.EmailAddress COLLATE SQL_Latin1_General_CP1_CS_AS
GO

SELECT a.*
FROM AdventureWorks.Person.Contact a
JOIN dbo.Contact b
ON a.EmailAddress = b.EmailAddress COLLATE SQL_Latin1_General_CP1_CI_AS
GO

Order SQL 2008 GRAND SLAM Today!
SQLUSA.com Home Page
SQL Server Training at www.sqlusa.com.
SQL Server 2008 Video Training at www.sqlusa.com.
SQL Server 2005 Training Videos at www.sqlusa.com.
Microsoft SQL Server 2000 Training Videos at www.sqlusa.com.

FREE SQL & Business Intelligence / OLAP Short Videos on YOUTUBE.com

Microsoft Community Contributor 2011
Invest in Your SUCCESS!

Search SQLUSA FREE SQL Server Articles & FREE T-SQL Scripts


Copyright 2005-2011, SMI Corp. All Rights Reserved.

SQL Server 2012 is a program product of Microsoft Corporation.
SQL Server 2008 is a program product of Microsoft Corporation.
SQL Server 2005 is a program product of Microsoft Corporation.
SQL Server 2000 is a program product of Microsoft Corporation.