Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Table Help!

Author  Topic 

jscot
Posting Yak Master

106 Posts

Posted - 2010-11-22 : 22:31:10
Hi guys,

I have one database with 48 tables and i am not sure how many total columns. My question is is there any way i can copy all columns with data type so i can paste in excel or text. I am creating mapping document i have to type all tables with columns. I just want to know is there any way i can save my typing ):. Thanks in advance.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-11-22 : 23:01:38
[code]SELECT t.table_name, c.column_name, c.data_type, c.numeric_precision, c.numeric_scale
FROM INFORMATION_SCHEMA.TABLES t
JOIN INFORMATION_SCHEMA.COLUMNS c
On c.table_name = t.table_name
ORDER BY
t.table_name, c.ordinal_position[/code]
Go to Top of Page

jscot
Posting Yak Master

106 Posts

Posted - 2010-11-22 : 23:17:07
Russell Thanks for prompt reply! quick question, After i run this query i can get column name and data type but how i can copy those column name and data type from SSMS ?
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-11-22 : 23:21:03
just click the result set, then ctrl-a, ctrl-c and paste it to excel.

if you need to automate it, use BCP or SSIS.
Go to Top of Page

jscot
Posting Yak Master

106 Posts

Posted - 2010-11-23 : 23:04:43
Sorry for late reply! you solve my problem, Thanks you. Your time, help us a lot. Please keep it up!
Go to Top of Page
   

- Advertisement -