- Right-click the database in SQL Management Studio
- Go to Tasks and then Export data, you'll then see an easy to use wizard.
- Your database will be the source, you can enter your SQL query
- Choose Excel as the target
- Run it at end of wizard
If you wanted, you could save the SSIS package as well (there's an option at the end of the wizard) so that you can do it on a schedule or something (and even open and modify to add more functionality if needed).
Option 2:
- Select menu item Query > Query Options.
- Set check box in Results > Grid > Include column headers when copying or saving the results.
After that, when you Select All and Copy the query results, you can paste them to Excel, and the column headers will be present.
Option3:
- Open Excel Data>Import/Export Data>Import Data Next to file name
- Click "New Source" Button On Welcome to the Data Connection Wizard,
- Choose Microsoft SQL Server. Click Next.
- Enter Server Name and Credentials.
- From the drop down box, choose whichever database holds the table you need.
- Select your table then Next.....
- Enter a Description if you'd like and click Finish.
When your done and back in Excel, just click "OK" Easy.
No comments:
Post a Comment