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.
| Author |
Topic |
|
hennie7863
Starting Member
12 Posts |
Posted - 2003-04-28 : 06:47:51
|
| Hi,i want to create a table which describes a table (fieldname, length, type, identity (yes/no), etc). With a stored procedure i want to create the specific table.Before i want to hack something i want to know if someone created something like this or could lead me to a solution.ThanxHennie |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-04-28 : 11:58:35
|
| Or try:SELECT * FROM INFORMATION_SCHEMA.TablesGOBrett8-) |
 |
|
|
hennie7863
Starting Member
12 Posts |
Posted - 2003-04-29 : 06:13:58
|
| Brett thnx for the info but it's not what i meant. I have a table (zelf - created) and this describes how to create a table (or more) with fieldname, type, length, identity Y/N. Then i create a stored procedure which reads this meta table and creates the tables as wanted. SPCreate_table (@Tablename)If someone calls this procedure with Create_table ("Customer") then i have to look in de metatable for Table "Customer" and create the desired table with the described fields. Edited by - hennie7863 on 04/29/2003 06:14:47Edited by - hennie7863 on 04/29/2003 06:15:24 |
 |
|
|
Andraax
Aged Yak Warrior
790 Posts |
Posted - 2003-04-29 : 06:18:36
|
| Hi Hennie.If you want only columns with correct datatypes etc. look into information_schema.tables and information_schema.columnsIt will be harder if you want indexes, triggers, constraints etc. but it can be done with a little investigation.You can also use SQL-DMO object library to script the tables, and store the entire creation script in your meta table if you like. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-04-29 : 09:29:48
|
| I see....(said the blind man).I know what you're trying to do, which is basically what data modeling tools out there do now.Do you use ERWin? Visio 2000 (don't know if that gens ddl or not), Embarcadero? Anyway all (except Visio) are kind of expensive, but worth their weight in Gold.However, if you want to continue, my advise would be to Mirror the INFORMATION_SCHEMA Views. The have mostly everything piece of information (almost) that you will need. Study their structures and build your own copies.It should be a (relatively) simple manner to do what you want.However, I only reccommend this as a DBA utility type thing, not for general users. My guess is that you'll end up with a mess on your hands.Good LuckBrett8-) |
 |
|
|
|
|
|
|
|