﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / How To Make Unique Constraint Case Sensitive  ? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 17:01:01 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: How To Make Unique Constraint Case Sensitive  ?</title><link>http://www.sqlservercentral.com/Forums/Topic1422388-392-1.aspx</link><description>[quote][b]gopinathreddy.d (2/20/2013)[/b][hr]I Have Table With Column With DataType Varchar(50) Which Is Having A Unique Constraint On That.For Example : I want To Insert These 3 Values Into Above Column'ABC'    'abc'     'Abc'  .... etcI Here Is My Problem,[b]If I Try To Insert Above 3 Values,Throws An Error  (UNIQUE KEY constraint 'XXXXXXXX'. Cannot insert duplicate key in object).[/b]My Requirement Is To Treat  Those 3 Values As Different Values And Insert Into That Column.Suppose If The Value Is Already There Like 'ABC' In The Column And If I try To Insert 'ABC' Again Then It It Should Through Me And ErrorBut Not With These Values   'abc'     'Abc'  ABc.... etc .It Should Treat Is As Different As We Can See Visually....Collation Setting On DataBase Level Is Case InSensitive.[b]Collation Setting On Column Level Is Case Sensitive.[/b]Any Suggestions Please.......[/quote]The two bolded statements above do not compute. Please post the DDL for the table. Indexes use the collations of the columns they reference. Per this proof-of-concept if the column were using a case-sensitive collation then you would be able to insert ABC, Abc and abc:[code="sql"]USE tempdb;---------------------------------IF EXISTS ( SELECT  *            FROM    sys.objects            WHERE   object_id = OBJECT_ID(N'dbo.test_collation')                    AND type IN ( N'U' ) )     DROP TABLE dbo.test_collation;CREATE TABLE dbo.test_collation (name VARCHAR(100) COLLATE SQL_Latin1_General_CP1_CI_AI); -- case-INsensitive collationCREATE UNIQUE INDEX [uix] ON dbo.test_collation (name);INSERT INTO dbo.test_collation(name)VALUES  ('ABC');INSERT INTO dbo.test_collation(name)VALUES  ('Abc'); -- error, as expected with a case=INsensitive collation---------------------------------IF EXISTS ( SELECT  *            FROM    sys.objects            WHERE   object_id = OBJECT_ID(N'dbo.test_collation')                    AND type IN ( N'U' ) )     DROP TABLE dbo.test_collation;CREATE TABLE dbo.test_collation (name VARCHAR(100) COLLATE SQL_Latin1_General_CP1_CS_AS) -- case-sensitive collationCREATE UNIQUE INDEX [uix] ON dbo.test_collation (name)INSERT INTO dbo.test_collation(name)VALUES  ('ABC')INSERT INTO dbo.test_collation(name)VALUES  ('Abc')  -- no error, as expected with a case=sensitive collationGO[/code]</description><pubDate>Thu, 21 Feb 2013 14:52:03 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: How To Make Unique Constraint Case Sensitive  ?</title><link>http://www.sqlservercentral.com/Forums/Topic1422388-392-1.aspx</link><description>[strike]Cant you just set the column to a case sensitive collation ?[/strike]edit : Column is already set to CSThat will teach me for replying before reading the entire post.</description><pubDate>Wed, 20 Feb 2013 21:48:30 GMT</pubDate><dc:creator>matak</dc:creator></item><item><title>How To Make Unique Constraint Case Sensitive  ?</title><link>http://www.sqlservercentral.com/Forums/Topic1422388-392-1.aspx</link><description>I Have Table With Column With DataType Varchar(50) Which Is Having A Unique Constraint On That.For Example : I want To Insert These 3 Values Into Above Column'ABC'    'abc'     'Abc'  .... etcI Here Is My Problem,If I Try To Insert Above 3 Values,Throws An Error  (UNIQUE KEY constraint 'XXXXXXXX'. Cannot insert duplicate key in object).My Requirement Is To Treat  Those 3 Values As Different Values And Insert Into That Column.Suppose If The Value Is Already There Like 'ABC' In The Column And If I try To Insert 'ABC' Again Then It It Should Through Me And ErrorBut Not With These Values   'abc'     'Abc'  ABc.... etc .It Should Treat Is As Different As We Can See Visually....Collation Setting On DataBase Level Is Case InSensitive.Collation Setting On Column Level Is Case Sensitive.Any Suggestions Please.......</description><pubDate>Wed, 20 Feb 2013 20:45:59 GMT</pubDate><dc:creator>gopinathreddy.d</dc:creator></item></channel></rss>