Link to home
Start Free TrialLog in
Avatar of parabellum
parabellum

asked on

Access a database and get table names

Hello,

I need to modify my client's database(he is using SQL Server 2005). I have the connection string so that i can connect to the database.

Is there a way that i can learn the table names that the database has and  even the data types that the tables contain ?

Or do i have to ask my client to tell me the table names and the column types/names ?

It would make my life a lot easier if there was a sql query that will retrieve table information from a database.
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
use --<ur db name here>

GO

--To get the Table names

select * from sysobjects

where xtype ='U'

--To get the Column names

select * from information_schema.columns

Where table_name like ''
SELECT TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME,DATA_TYPE,ORDINAL_POSITION,COLLATION_NAME,IS_NULLABLE
FROM information_schema.columns