Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 primary key

Author  Topic 

pnpsql
Posting Yak Master

246 Posts

Posted - 2011-12-14 : 04:39:59
hi team, i need to create a primary key on table, but may be there is
already a primary, i need to check if already exists then need not to create .
please help me..

challenge everything

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-14 : 04:57:21
try

sp_pkeys 'table name'

if there's pk it will return column info

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

hirecrishecom

4 Posts

Posted - 2011-12-14 : 05:34:57
First of all you know about what is Primary key ...
On Sql in your table click right click on field in which you want to set primary key ..
if you want to know then there is tree view in which keys appear on that then click on that ...
OR
try this
sp_Pkeys "Table name"

<removed signature spam>
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2011-12-14 : 07:55:11
OR

You could try sp_pkeys

Mark this as accepted if this helped you!


http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -