Geeks Talk

Prepare for your Next Interview




How can we create unique key

This is a discussion on How can we create unique key within the SQL Server forums, part of the Databases category; i am having one table here username is there i want to create it as unique how can...


Go Back   Geeks Talk > Databases > SQL Server

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-21-2008
Junior Member
 
Join Date: Mar 2008
Location: hyderabad
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
boreddy is on a distinguished road
How can we create unique key

i am having one table
here username is there i want to create it as unique
how can
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-21-2008
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,365
Thanks: 7
Thanked 123 Times in 111 Posts
debasisdas will become famous soon enoughdebasisdas will become famous soon enough
Re: How can we create unique key

You need to create an unique constraint on the field.
Reply With Quote
  #3 (permalink)  
Old 04-22-2008
Contributing Member
 
Join Date: Jun 2007
Location: Delhi, India
Posts: 49
Thanks: 0
Thanked 20 Times in 17 Posts
vikasvaidya is on a distinguished road
Re: How can we create unique key

Quote:
Originally Posted by boreddy View Post
i am having one table
here username is there i want to create it as unique
how can
u can use the following script

ALTER TABLE TableName
ADD CONSTRAINT uk_username UNIQUE KEY (UserName)


---V V---
Vikas Vaidya
Reply With Quote
  #4 (permalink)  
Old 05-08-2008
Junior Member
 
Join Date: May 2008
Location: banglore
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
parepalli9 is on a distinguished road
Re: How can we create unique key

hi, using constraint at creation table. other we can use alter the particular column....
ALTER TABLE TableName
ADD CONSTRAINT uk_username UNIQUE KEY (UserName)
Reply With Quote
The Following User Says Thank You to parepalli9 For This Useful Post:
Reply

  Geeks Talk > Databases > SQL Server


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
what is unique key priyasp_msit SQL Server 3 04-22-2008 04:45 AM
Unique key and Single Query mail2das.ashok SQL 2 02-11-2008 03:53 AM
English Words which are Unique K.K.Rajiv Brainteasers 12 12-15-2007 12:31 AM
unique login name smita76 Unix/Linux 1 12-09-2007 02:09 PM
Unique with NotNull?? vcyogi SQL Server 2 06-08-2007 09:15 AM


All times are GMT -4. The time now is 01:30 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved