•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 425,815 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,116 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 1155 | Replies: 3
![]() |
•
•
Join Date: Apr 2008
Posts: 295
Reputation:
Rep Power: 1
Solved Threads: 41
•
•
•
•
After creating the table i tried to specify the unique key constraint in sql server 2005 but its asking for the expression. I don't know what to give in that expression. can u please help me out in this.
thanx in advance.
pls post your create-table command and specify what column should be unique.
•
•
Join Date: May 2008
Posts: 13
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
•
•
pls post your create-table command and specify what column should be unique.
I've not used create table command to create the table.
in SQl server management studio u've an option to create a table by right clicking on the table option u'l be providede with a new table option there i've created.
table UserList
user_id int (Primary key)
f_name varchar(50),
login varchar( I should make this field has unique)
address varchar(250)
email varchar(50)
•
•
Join Date: Apr 2008
Posts: 295
Reputation:
Rep Power: 1
Solved Threads: 41
•
•
•
•
I've not used create table command to create the table.
in SQl server management studio u've an option to create a table by right clicking on the table option u'l be providede with a new table option there i've created.
table UserList
user_id int (Primary key)
f_name varchar(50),
login varchar( I should make this field has unique)
address varchar(250)
email varchar(50)
If table already exists you can try this to make column login unique:
sql Syntax (Toggle Plain Text)
ALTER TABLE UserList ADD CONSTRAINT consName UNIQUE FOR login;
Further information: http://msdn.microsoft.com/en-us/library/ms190273.aspx
You can't add UNIQUE constraint if column already holds duplicate values.
If you have chance to re-create this table, simple write: create table UserList ( ..., login varchar(50) UNIQUE ...., ...); (but be careful not to lose data!)
krs,
tesu
Last edited by tesuji : May 28th, 2008 at 8:54 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the MS SQL Forum
- Previous Thread: Need help ordering records
- Next Thread: Permission problems on SQL Management Studio


Linear Mode