Pages

Saturday, September 27, 2008

Primary Key in SQL Server

In next couple of posts i will explain about some very usefull stored procedures in SQL Server.

SP_PRIMARYKEY: SP_PRIMARYKEY TABLE,COLUMN1[, COLUMN2,....COLUMN(N)]

If you don’t know the syntax of primary key creation then this is the right procedure which you can use to create primary key. This stored procedure is used to apply the primary key constraint on a column or columns that is passed as a parameter.

The column1, column2, and column(n) parameters contain the column names on which you want to create the primary key constraint. A primary key can contain more than one column.

Use Pubs
GO
SP_PRIMARYKEY 'HR.EMP','empid
GO

No comments: