Hi,
I have a table as below
CREATE TABLE [dbo].[tblLocationMaster](
[LocationID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[LocationName] [varchar](50) NOT NULL,
[Description] [varchar](500) NULL,)
I want to add a constraint on LocationName so that duplicate values do not get saved in table... How to do this?
Adding constraint to varchar type column
5 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Dorababu MekaRank #457 · 5.5K reputationPosted Sep 18, 2011, 11:54 PM EDT
Pravin MoreRank #1,419 · 1.2K reputationPosted Sep 19, 2011, 1:01 AM EDT
here is your modified query.....
CREATE TABLE [dbo].[tblLocationMaster](
[LocationID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[LocationName] [varchar](50) NOT NULL UNIQUE,
[Description] [varchar](500) NULL,)
hope this will solve ur problem..
Thanx ,
Pravin
Nethra R SRank #6,347 · 269 reputationPosted Sep 19, 2011, 2:45 AM EDT
Dorababu MekaRank #457 · 5.5K reputationPosted Sep 19, 2011, 3:06 AM EDT
Pravin MoreRank #1,419 · 1.2K reputationPosted Sep 19, 2011, 4:34 AM EDT
Thanx,
Pravin.