Solved

MS SQL 2005 Express :: Give non key field UNIQUE constraint?

Posted on 2007-11-21
6
2,154 Views
Last Modified: 2008-11-11
Hi Experts,

Please give me all the necessary steps in order to set a non-key field to unique constraint.
Note that I am using the "SQL Server Management Studio Express".

Thanks in advance!
0
Comment
Question by:Marius0188
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20326407
do you mean just create unique constraint?
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20326415
if you have   create table tbl ( f1 int, f2 char(1), f3 bit, f4 datetime )
and you want to make sure that f4 (the datetime) is unique, you'd add a constraint using

alter table tbl add constraint uq_f4 unique(f4)
0
 
LVL 25

Accepted Solution

by:
imitchie earned 500 total points
ID: 20326423
so the steps:
in object explorer, find the database you want to work on. right-click, new query
type the SQL statement
press F5 to run the statement
0
 

Author Comment

by:Marius0188
ID: 22168142
Can you provide the steps in the Studio Management Tool?
For example:
Select "Contstraints", right click and select "New Constraint".... etc.

Thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question