Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unique constraint
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Unique constraint
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01190628
Message ID:
01190628
Views:
68
Can I add a constraint to a table to ensure that a column is unique? The column is not the PK column.
Considder the following table:
CREATE TABLE [dbo].[User](
	[UserId] [uniqueidentifier] NOT NULL,
	[Login] [nvarchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Password] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[FirstName] [nvarchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[LastName] [nvarchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[UserId] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
I would like to make the Login column unique.
Semper ubi sub ubi.
Next
Reply
Map
View

Click here to load this message in the networking platform