Sunday, May 25, 2014

Getting list of Tables,Columns ,Constraints

Getting list of Tables
To get list of Tables available in the database
Use the following select statement.

select * from sys.tables
select * from INFORMATION_SCHEMA.TABLES
select * from sys.objects where type='u'

Getting list of Columns
select * from sys.columns
select * from sys.columns where object_id=object_id('emp')
select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='emp'


Getting list of Constraints
select * from INFORMATION_SCHEMA.TABLE_CONSTRAINTS whereTABLE_NAME='emp'
sp_help 'emp'
sp_helpconstraint 'emp'


You can get complete details of a table that is columns and constraints by using the stored procedure
sp_help


No comments:

Post a Comment

Thank you for visiting my blog

Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...