Solved

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

Posted on 2007-11-21
6
2,147 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
  • 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Trigger selecting another database 4 33
Upgrading SQL 2005 Express to 2008 R2 Express 31 65
Strange msg in the SSMS pane 13 47
Sql query 107 22
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now