SQL 2005 - call to get all tables in a DB

  • Thread starter Thread starter JPS
  • Start date Start date
J

JPS

What kind of a query do I use when all I want to do is get a lst of al
of the tables in a database and their fields. I'm trying to get schema
information and GetSchema give you the field type but not the value.
Theis (below) does not work.

sqlCmd.CommandText = "SELECT * FROM INFORMATION_SCHEMA.COLUMNS";
SqlDataReader sqlDr = sqlCmd.ExecuteReader ( );
 
the db is the "master".

so, in your connect string, specify it, or
you can experiment with

"SELECT * FROM master.dbo.INFORMATION_SCHEMA.COLUMNS";
 
Hi,



sloan said:
the db is the "master".

so, in your connect string, specify it, or
you can experiment with

"SELECT * FROM master.dbo.INFORMATION_SCHEMA.COLUMNS";


In 2005 at least you have a INFORMATION_SCHEMA.COLUMNS in the DB itself,

And btw you CANNOT prefix it with dbo. INFORMATION_SCHEMA. is the correct
owner.
 
Ok..yeah, thanks for the correction.

dbo. is a typing habit sometimes.

at least I said "experiment with"...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top