December 29, 2009 at 3:06 pm
I have a database on SQL 2005. I would like to get help with sql to create a listing of its table names, its associated column names, keys, create date and row counts all on one document if possible.
Any input is appreciated
December 29, 2009 at 3:51 pm
You can start by running the standard Disk Usage by Tables report. This report will not give you columns for the table - but gives you everything else you are looking for.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
December 29, 2009 at 4:30 pm
Can you please show me how to run the standard Disk Usage by Tables report ?
Many Thanks
December 29, 2009 at 4:35 pm
select *
from information_schema.routines
Select*
From Information_schema.Tables
| If in Doubt...don't do it!! |
December 29, 2009 at 6:45 pm
Right-click on the database, select Reports | Standard Reports | Disk Usage by Tables
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
January 3, 2010 at 12:12 am
Here's another option...
USE EnterYourDBNameHere
GO
SELECT *
FROM sys.Tables
GO
Hope this helps - Mark Mathews
January 3, 2010 at 2:34 am
mmathews 87112 (1/3/2010)
Here's another option...USE EnterYourDBNameHere
GO
SELECT *
FROM sys.Tables
GO
Hope this helps - Mark Mathews
But that won't list the columns or keys associated with the table so it doesn't really answer the question asked
January 3, 2010 at 3:42 am
like folks have commented, it is a start. the question originally asked, did not have enough specifics, it was broad and high level and looked like needing some direction.
anyways, these other tables can be joined to sys.tables to get some additional info:
sys.columns, sys.types, sys.indexes, sys.index_columns.
it is probably a good idea to read and understand more about these tables from SQL Server Books On Line.
also, something like this has been done numerous times and if you search enough you can probably find a script out somewhere. but i would strongly recommend to spend some time reading and understanding the above tables first.
January 3, 2010 at 3:46 am
I'm not entirely sure what you need or what you are after...In terms of table space used you can try, amongst others, the tip provided in this link:
http://www.mssqltips.com/tip.asp?tip=1177
In terms of table information this little undocumented stored proc can be useful to loop around all tables in a database, and SP_Help maywell contain alot of the information that you need.
exec sp_MSforeachtable
'sp_help''?'''
You can also use stored proc to get a row count of each table:
create table #NoRows (tablename varchar(128), NoRows int)
exec sp_MSforeachtable 'insert into #NoRows select ''?'', count(*) from ?'
select * from #NoRows
order by NoRows
drop table #NoRows
I'm not sure if this answers your question entirely but hopefully it helps.
Gethyn Elliswww.gethynellis.com
January 3, 2010 at 3:51 am
Here are some FAQ queries asked out of the SQL Server System Catalog
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply