Solved

SQL Data Export to Excel

Posted on 2016-08-22
5
60 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 32

Assisted Solution

by:Stefan Hoffmann
Stefan Hoffmann earned 250 total points
Comment Utility
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
Comment Utility
What's in the job?
0
 
LVL 28

Accepted Solution

by:
Ryan McCauley earned 250 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

762 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

10 Experts available now in Live!

Get 1:1 Help Now