You can use the OBJECTPROPERTY() function in SQL Server to check whether or not an object is a primary key.
To find out whether an object is a primary key, pass the object ID as the first argument, and IsPrimaryKey as the second argument. The function returns a 1 or a 0 depending on whether or not it’s a primary key.
A return value of 1 means that it is a primary key, and a value of 0 means that it’s not.