dbTalk Databases Forums  

How to export SQL databases to MS Excel automaically / by batch

microsoft.public.sqlserver.tools microsoft.public.sqlserver.tools


Discuss How to export SQL databases to MS Excel automaically / by batch in the microsoft.public.sqlserver.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Simon Kwong
 
Posts: n/a

Default How to export SQL databases to MS Excel automaically / by batch - 08-02-2009 , 12:35 PM






Hi,

I have 20-30 SQL database files. How can I to export the data into Excel
files automatically or by batch (using macros)? Any built-in command in sql
server can help?
Thanks
Simon

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: How to export SQL databases to MS Excel automaically / by batch - 08-02-2009 , 05:25 PM






Simon Kwong (SimonKwong (AT) discussions (DOT) microsoft.com) writes:
Quote:
I have 20-30 SQL database files. How can I to export the data into Excel
files automatically or by batch (using macros)? Any built-in command in
sql server can help?
If you just want the data in a format that Excel can read, you could
use BCP which is a command-line program:

BCP db..tbl out tbl.csv -c -t; -T

db..tbl - is your database and table.
out - you are exporting data.
tbl.csv - the output file.
-c - character format. Use -w if you have Unicode data.
-t; - Semicolon as separator. What is the expected delimiter in Excel
for a CSV file depends on regional settings. In my case it's
semicolon, but it may be comma for you.
-T - Login with integrated security; use -U and -P if you use an
SQL login.

Note that this will not include any column headers in the file.

Another option is to look at the Export and Import wizard, which you
find under Tasks when you right-click a database in Mgmt Studio.

And finally, you may want to look at SQL Server Integration Services,
which is the prime tool for export and import of data. (But which I've
never used myself.) Here you can design packages, schedule them etc.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.