Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

get rich schema details of all or some tables

By bob chatsrinopkun, 2006/08/30

to get information about tables+columns+primarykeys+foreignkeys+identity, i firstly used SQL server built-in INFORMATION_SCHEMA.xxx. however, my company have various DBAs and each of them owns objects. when using INFORMATION_SCHEMA.xxx, it retrieves data based on current login (version 2005 resolves this schema v.s. object owner problem already... yeah) , which bring me a great trouble. if you want to see problems, try to use INFORMATION_SCHEMA.xxx to get primary key details of objects not own by current login. so i develop my own version, which is not related to login. try for yourself. btw... support version 7/2000/2005


the process uses two functions together
1) infFKfrom to get foreign keys
2) infTB to compose fk-data with others

you can use the function these ways...
select * from infTB('%') --> to get all info of user tables
select * from infTB('%some%table%') --> to get some

good luck

Total article views: 520 | Views in the last 30 days: 3
 
Related Articles
FORUM

Objects Accessible by a Login / User

Objects Accessible by a Login / User

FORUM

How to Find Object Versions

How to Find Object Versions ,(Procedure ,views,Fucntions..)

SCRIPT

Find all objects in Server Owned by a Login

Find every object in every database owned by a particular Login.

FORUM

How do I version control SQL Server objects?

Version control SQL Server 2008 objects

FORUM

Add SQL Objects to TFS/ Version Control

Trying to add SQL Objects to Source Control and versioning

 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones