I am searching for a query that tell me the NAME of the primary-key of a table
example: In oracle I do this
select CONSTRAINT_NAME from user_constraints where table_name = 'CT' AND CONSTRAINT_TYPE ='P'
how to do that in sybase ?
A primary key, also called a primary keyword, is a column in a relational database table that's distinctive for each record. It's a unique identifier, such as a driver's license number, telephone number with area code or vehicle identification number (VIN). A relational database must have only one primary key.
SQL PRIMARY KEY on ALTER TABLE. ADD CONSTRAINT PK_Person PRIMARY KEY (ID,LastName); Note: If you use ALTER TABLE to add a primary key, the primary key column(s) must have been declared to not contain NULL values (when the table was first created).
Use MachineName property to get the computer name on which the SQL Server instance is running. For a cluster, it returns the virtual server name. Select SERVERPROPERTY('MachineName') as 'MachineName'.
Try this way:
select name
from sysindexes
where indid > 0
and status2 & 2 = 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With