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)
 BCP Tables & Column Names into CSV

Author  Topic 

jbrown7232
Starting Member

22 Posts

Posted - 2010-06-28 : 13:48:17
Hello,

I need to BCP out all the tables and column names from my database [Billing] into a CSV or .xls files.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-06-28 : 14:13:49
You can simply bcp out the INFORMATION_SCHEMA.COLUMNS table, or a subset of the data via a queryout.

bcp "select table_name, column_name from Billing.INFORMATION_SCHEMA.COLUMNS order by table_name, ordinal_position" queryout E:\Folder1\File1.csv -t, -c -Sserver1\instance1 -T -r\r\n

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jbrown7232
Starting Member

22 Posts

Posted - 2010-06-28 : 15:12:58
I am sorry I need the data for each table into a CSV file and each table need to contain the column headings. Thanks This is close
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-06-28 : 15:21:34
You can use SSIS to do that.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -