|
-
Sep 21st, 2004, 04:09 AM
#1
Thread Starter
PowerPoster
detecting database structure
Hi there.
I am very new to this, and we are kind of going to start doing this for a project.
I need to know, is it possible to detect the structure of a table in a specified database in SQL?
if so - how would you do that? what is brought back from sql when requested?
The other thing is....
when it comes to populating a database, how do you populate the database by record? I mean, lets say if table A has 5 fields, and table B has 9 fields, how do you populate the tables (auto detecting) for all fields in the table?
Thank-you
-
Sep 22nd, 2004, 07:26 PM
#2
Addicted Member
Detecting the structure of a table is a database dependent thing, that is, the answer varies depending on which database you are using. For example, MS SQL Server, if you had a table called "Procedures" here's how you would get information about it:
Code:
SELECT *
FROM syscolumns c, sysobjects t
WHERE t.name = 'Procedures' AND
t.id = c.id
ORDER BY c.colorder
Most other databases have some similar set of "system" tables that allow you to map your table structure.
Given the above, you should be able to dynamically craft an insert statement to populate any of your existing tables.
cudabean
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|