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
 Urgent Query

Author  Topic 

chbala85
Starting Member

49 Posts

Posted - 2013-12-03 : 04:59:30

Hi All,

I required query like in particular database
all tablename,columnname,constrainttype,constraintname

please help me.

Thanks,
Krish.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-12-03 : 05:19:55
you can get the required information by querying the Information Schema Views

http://technet.microsoft.com/en-us/library/ms186778.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-03 : 06:26:29
you should be using COLUMNS,CONSTRAINT_COLUMN_USAGE and TABLE_CONSTRAINTS views in INFOMRATION_SCHEMA for this

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

vinay_555
Starting Member

10 Posts

Posted - 2013-12-03 : 08:16:12
Execute Sp_help table_name

Ur Issue will be resolved
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-03 : 09:25:15
quote:
Originally posted by vinay_555

Execute Sp_help table_name

Ur Issue will be resolved


for viewing its ok
however if the attempt is to use this resultset further then sp_help wont work as its gives this info in multiple resultsets

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-12-04 : 00:31:07
quote:
Originally posted by visakh16

quote:
Originally posted by vinay_555

Execute Sp_help table_name

Ur Issue will be resolved


for viewing its ok
however if the attempt is to use this resultset further then sp_help wont work as its gives this info in multiple resultsets

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs




OR for a particular database all tablename, .. . as what OP had specified, using sp_help might not be very practical at all


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -