Solved

SQL Data Export to Excel

Posted on 2016-08-22
5
64 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
5 Comments
 
LVL 33

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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 will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

816 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now