I want to find all column names in all tables in all databases. Is there a query that can do that for me? The database is Microsoft SQL Server 2000.
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
try this:
or for more detail:
EDIT
here is a basic example to get all columns in all databases:
EDIT SQL Server 2000 version
EDIT
based on some comments, here is a version using
sp_MSforeachdb
:Some minor improvements
->previous answers weren't showing all results
->possible to filter on column name by setting the column name variable
Why not use
You can make it DB specific with
Better way for you
try the below query
gives list of tables containing ID column from all databases.
Normally I try to do whatever I can to avoid the use of cursors, but the following query will get you everything you need:
I added a where clause in the main query (ex: B.TABLE_NAME LIKE ''%%'' AND B.COLUMN_NAME LIKE ''%%'') so that you can search for specific tables and/or columns if you want to.