SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Urgent Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chbala85
Starting Member

49 Posts

Posted - 12/03/2013 :  04:59:30  Show Profile  Reply with Quote

Hi All,

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

please help me.

Thanks,
Krish.

khtan
In (Som, Ni, Yak)

Singapore
17642 Posts

Posted - 12/03/2013 :  05:19:55  Show Profile  Reply with Quote
you can get the required information by querying the Information Schema Views

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


KH
Time is always against us

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 12/03/2013 :  06:26:29  Show Profile  Reply with Quote
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

India
10 Posts

Posted - 12/03/2013 :  08:16:12  Show Profile  Reply with Quote
Execute Sp_help table_name

Ur Issue will be resolved

Edited by - vinay_555 on 12/03/2013 08:18:58
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 12/03/2013 :  09:25:15  Show Profile  Reply with Quote
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)

Singapore
17642 Posts

Posted - 12/04/2013 :  00:31:07  Show Profile  Reply with Quote
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
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000