Wednesday, 12 April 2017

SQL Create table with primary key and UNIQUE key

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[MyTable](
 [SNo] [int] NOT NULL,
 [UserName] [int] NOT NULL,
 [Password] [nvarchar](50) NULL,
 CONSTRAINT [UQ_MyTable_UserName] UNIQUE NONCLUSTERED
(
 [UserName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO