Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

T-SQL way to export from SQL table to .csv/.xlsx ?

Posted on 2013-01-24
8
Medium Priority
?
2,308 Views
Last Modified: 2013-01-25
Hi All

Question:  Is there a T-SQL way to export data from a SQL table to a .csv or .xlsx?
I'm familiar with SSIS, but would like to avoid the work and overhead if that is possible.

I have an Access 2010 FE / SQL 2008 R2 backend, and the backend contains a table that is too wide to be linked to Access, so afaik I can't take advantage of Access' export specs.  

Ultimately I'll have an Access form that allows a user to choose between different exports, then Access VBA will execute a Stored Procedure that populates the table with data.  I just need to figure out how to build the piece that exports it.

Thanks in advance.
Jim
0
Comment
Question by:Jim Horn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 70

Assisted Solution

by:Scott Pletcher
Scott Pletcher earned 700 total points
ID: 38814606
You can use "bcp" to export to a csv format.

I don't know of any way to directly export to Excel from SQL w/o using SSIS/package.
0
 
LVL 11

Assisted Solution

by:SThaya
SThaya earned 800 total points
ID: 38814619
0
 
LVL 11

Assisted Solution

by:SThaya
SThaya earned 800 total points
ID: 38814624
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 66

Author Comment

by:Jim Horn
ID: 38814785
<Going the SSIS wizard route for the moment.  I'll change paths to either bcp or the SSIS designer if this doesn't work>

I went into the db, right click Tasks > Export Data ... and followed the wizard.

Three questions:
(1)  Once saved, is there a T-SQL command that can be executed to execute the package?
(2)  Where in SSMS can I view the saved package?
(3)  I'm receiving the below error message when I attempt to save the package, which I'm guessing is a privs issue I need to work out with my DBA's:
errmsg
Thanks.
0
 
LVL 66

Author Comment

by:Jim Horn
ID: 38815115
@SThaya

I pieced together the below T-SQL from your links, and received the below error message:
BCP errmsg
I'll work out the privs with the DBA's as well.
0
 
LVL 66

Author Comment

by:Jim Horn
ID: 38816691
Splitting points.  I'm sure that bcp would have worked, as it executed on my personal box, but due to restrictions at my company (shocking I know) I'm not able to execute bcp.  Or save SSIS packages to the server.  

So, I'm creating SSIS using the wizard, then modifying to fit my template.

Thanks.
Jim
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
ID: 38816834
Or save SSIS packages to the server.  
You don't have to (in fact you probably should not) save the SSIS packages on the same server as SQL Server.
0
 
LVL 66

Author Comment

by:Jim Horn
ID: 38818602
Anthony - Yep.  I don't have any experience with SSIS on the server, as every place I've worked we've ran them off of the file system.  Not sure what the DBA resistance is to SSIS on the server.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Viewers will learn how the fundamental information of how to create a table.

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question