I have like 20 or so tables in the database RentalEase and I want to print them out (physically) so I can look at them easier. I don\'t care too much about what data is in t
You can always inspect the INFORMATION_SCHEMA views to find all the interesting information about tables and their columns.
It's not called "describe" per se - but this query will show you lots of information:
select * from Information_schema.Columns
where table_name = '(your table here)'
Marc
In Management Studio,
This will produce a script file containing all of the selected file schema definitions.
Here is a script I wrote that simply lists each table and their columns in a format like:
Table Columns
table1 column1,column2...columnX
The script is:
declare @max_tables int
declare @max_columns int
declare @sql nvarchar(400)
declare @x int
declare @y int
declare @table varchar(50)
declare @columns varchar(800)
create table #c ([Table] varchar(50),[Columns] varchar(800))
select ROW_NUMBER() OVER(ORDER BY name) AS Row, name
into #table_list
from sys.objects
where type_desc = 'USER_TABLE'
order by name
set @max_tables = (select count(*) from sys.objects where type_desc = 'USER_TABLE')
set @y = 0
while @y < @max_tables
begin
set @y = @y + 1
set @table = (select name from #table_list where row = @y)
create table #t (c int)
set @sql = 'select count(*) as c from Information_schema.Columns where table_name = ''' + @table + ''''
insert into #t exec sp_executesql @sql
set @max_columns = (select top 1 c from #t)
DROP TABLE #t
set @x = 0
set @columns = ''
while @x < @max_columns
begin
set @x = @x + 1
set @columns = @columns + (select column_name from Information_schema.Columns where table_name = @table and ordinal_position = @x)
if @x < @max_columns set @columns = @columns + ', '
end
insert into #c select @table,@columns
end
select * from #c
DROP TABLE #c
DROP TABLE #table_List
You can use Database Schema Diagram Design Tool. Just drop all the tables there, and you will get the diagram of you database including all keys
try:
sp_help <table_name>