Solved

SQL Data Export to Excel

Posted on 2016-08-22
5
69 Views
Last Modified: 2016-09-26
i use ms sql >> sql agent >> create a job >> and export data into excel. See attached.
I want the columns inside of the cells inside of excel. Just like normal look.

How can I do that?
test3.xls
0
Comment
Question by:ITsolutionWizard
[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
5 Comments
 
LVL 34

Assisted Solution

by:ste5an
ste5an earned 250 total points
ID: 41766546
Your attachment is not readable.

Either you concat(enate) the contents in a T-SQL statement(s) in your job or - depending on the kind of usage of those Excel files - use a macro to format it accordingly (in the personal workbook).
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 41766814
What's in the job?
0
 
LVL 28

Accepted Solution

by:
Ryan McCauley earned 250 total points
ID: 41767635
I can't read your sheet (like others), but I'd recommend that you format a blank excel document the way you want, and then export the data into it using OPENROWSET. If you wanted to keep a copy of the template, you can have a step that uses xp_cmdshell to make a copy of the file first with a new name, then exports the data into the new file and leaves the original intact.

There's an example available at this SO question:

DECLARE @myfile varchar(800)

SET @myfile = 'C:\template.xls'

EXEC ('
insert into OPENROWSET(''Microsoft.Jet.OLEDB.4.0'', 
''Excel 8.0;Database=' + @myfile + ';'', 
''SELECT * FROM [SheetName$]'') 
select * from myTable
')

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

732 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