List Primary Key and structure of table like Column names,datatypes ,maximum character length

Teena
Posted by Teena under Sql Server category on | Points: 40 | Views : 3095
To list Primary key

Specify  table to get Primary key .For example: login
SELECT column_name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE OBJECTPROPERTY(OBJECT_ID(constraint_name), 'IsPrimaryKey') = 1 AND table_name = login


Structure of table like Column names,datatypes ,maximum character length

Specify table .For eg: login


SELECT column_name,data_type,character_maximum_length  FROM information_schema.COLUMNS WHERE table_name=login

Comments or Responses

Posted by: Ponnu on: 4/26/2011 Level:Starter | Status: [Member] | Points: 10
Very informative ..
Posted by: Teena on: 4/26/2011 Level:Starter | Status: [Member] | Points: 10
Thanks Ponnu for ur reply

Login to post response