3

I use an excel 2010 template, and an existing SQL 2012 script. Instead of pulling the data and then pasting it into the excel template, I'd like to imbed the sql script in the template. My thought is to have a spot to enter the ID number, and the template updates with just that information. Any suggestions? I enherited the process, but not the knowledge to make this update.

4
  • So, it sounds like you have an Excel file. You'd like to enter a record id into a field in Excel, Run a Sql 'Script,' and get back the data that corresponds to the ID that you entered. Is that right? Is the script just a SQL query? Or is it some kind of VBA Macro? Commented Aug 24, 2018 at 13:54
  • This thread seems like a perfect fit for your goal. It might be a little much so you may need to spend some time learning how to automate excel with macros and vba. Commented Aug 24, 2018 at 13:56
  • Why dont you use SSIS. you copy your excel template and insert data from your sql script into Excel. Commented Aug 24, 2018 at 14:02
  • Greenspark, it is just a sql query, and yes, that sexactly what i'm looking to do. Commented Aug 28, 2018 at 14:00

1 Answer 1

0

You can import data from SQL Server into Excel without Macro or SSIS‌ package.

1) Save your query as a VIEW‌ in SQL Server. I Called mine V1.
2) Go to Excel and click on your desired sheet and choose "DATA" ribbon and choose "From SQL‌ Server".
enter image description here




3) Fill the your SQL server specs.
enter image description here




4) choose the Database and View.
enter image description here




5) For the next visards just press "Next" and "Finish".
6) If you wanna see changes in your query results just press "Refresh all" enter image description here




I hope it helps you with your problem. If you want to filter on your data before it loads into Excel this link is useful:Calling a Stored Procedure from Excel with multiple parameters

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.