Solved

write SQL Server 2 Excel

Posted on 2012-04-07
5
304 Views
Last Modified: 2012-04-27
I know there must be a way to write to  cells within excel from sql Server.  This is possible to do in access.

I need VBA code (Function) that will write a stored procedure results to a user defined location on a excel workbook.

Lets say the SP returns 6 records (each records contains five fields).  I want to dump the results to cell "A1" or any other location in the workbook.

                  Cell A1   Cell B1    Cell C1       Cell D1    Cell E1
  record 1  FName   LName     Address     city          State
  record 2  FName   LName     Address     city          State
.
.
.
  record 6  FName   LName     Address     city          State
0
Comment
Question by:tru-numbers
  • 3
  • 2
5 Comments
 
LVL 33

Expert Comment

by:Norie
Comment Utility
So you need to do it in Access?

You could do this using VBA and ADO in Excel.

If you do need it in Access you could set up a pass through query to return the results, then export the results to Excel.
0
 

Author Comment

by:tru-numbers
Comment Utility
Yes that is a possibility, but the user database is in SQL Server 2005.  The DB has 1000 users worldwide.
0
 
LVL 33

Expert Comment

by:Norie
Comment Utility
Which is a possibility?

The pass through query in Access or pulling directly from SQL Server using VBA in Excel?
0
 

Author Comment

by:tru-numbers
Comment Utility
I must pull diectly from sql server!
0
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
Comment Utility
You can use VBA with ADO for that.
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 collection of functions covers all the normal rounding methods of just about any numeric value.
My experience with Windows 10 over a one year period and suggestions for smooth operation
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

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

12 Experts available now in Live!

Get 1:1 Help Now