Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

constraints on columns while creating the table Expand / Collapse
Author
Message
Posted Tuesday, March 24, 2009 1:21 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, February 18, 2013 9:50 PM
Points: 119, Visits: 650

Hi All,

I have a small query.

I want to create a table Material
In this table i have two columns coulmn1 and column2 which should be unique.

What constraints should be placed on this columns so that the table should accept only unique values.

For one column i can use primary key.
My question for the other column what i have to do excatly.

Thanks,
Sandhya
Post #682751
Posted Tuesday, March 24, 2009 1:24 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Sunday, November 4, 2012 12:23 PM
Points: 2,087, Visits: 3,932
Hi Sandhya

Here an example:
CREATE TABLE test
(
column1 int not null,
column2 int not null,
CONSTRAINT PK_test PRIMARY KEY CLUSTERED (column1),
CONSTRAINT AK_test_column2 UNIQUE (column2)
)

Greets
Flo



The more I learn, the more I know what I do not know
Blog: Things about Software Architecture, .NET development and T-SQL

How to Post Data/Code to get the best Help How to Post Performance Problems
Post #682756
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse