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
 Database Design and Application Architecture
 Dynamic data dictionaries

Author  Topic 

vineet99
Starting Member

1 Post

Posted - 2012-09-12 : 00:05:22
Hi,

I am fairly new to SQL and am trying to create a stored procedure which dynamically generates a data dictionary for any database. Currently I have a stored procedure which given tablename and schema name as parameters generates the dictionary for that database. But I want to give the database name as parameter so that the dictionary is generated for any database. Is it even possible to do this? Please let me know.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-12 : 00:09:59
its possible. you just need to reference dbname in table name and use dynamic sql

ie as


EXEC('select * FROM ' + @dbname + '.INFORMATION_SCHEMA.TABLES')


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2012-09-16 : 00:00:01
I wrote a shareware app that does this, see the link in my sig. works for many other DBMS besides MSSQL.


elsasoft.org
Go to Top of Page
   

- Advertisement -