grimmettm Posted April 7, 2004 Posted April 7, 2004 Can anyone please tell me how to retrieve all tables in an SQL server database. I know that it can be done with an OleDB connection using the GetOleDbSchemaTable method. But the GetSchemaTable method for the SqlConnection only returns column schema. Any help is greatly appreciated. Thanks! Cheers!~ :D Quote
grimmettm Posted April 8, 2004 Author Posted April 8, 2004 I found the answer! You CAN'T get the table schema from SQL Server using the GetSchemaTable function. In order to list all of the FIELDS in a table, you use the GetSchemaTable function. In order to list all tables in a given database, I found that selecting the NAME from sysobjects table where xtype = 'n' would retrieve all tables in the desired database. the xtype column is used to identify databases. This may be unique to each useage, but it is a starting point! Cheers!~ Quote
Moderators Robby Posted April 8, 2004 Moderators Posted April 8, 2004 You can use these objects in Query Analyzer, filter by Type or xType (In Master) SELECT * from sysdatabases (In Master and your DB) SELECT * from sysobjects Quote Visit...Bassic Software
mavel Posted April 13, 2004 Posted April 13, 2004 Yes, but when I want to get all the tables I use antoher where condition: type='U'. I think it's safer. Quote
Moderators Robby Posted April 13, 2004 Moderators Posted April 13, 2004 Isn't that what I said "...filter by Type or xType" Quote Visit...Bassic Software
MyGeneration Posted April 14, 2004 Posted April 14, 2004 Yes, use the INFORMATION_SCHEMA VIEWS, IE, SELECT * from INFORMATION_SCHEMA.SCHEMATA MyGeneration Software We are the meta-data experts http://www.mygenerationsoftware.com/ Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.