extracting to a report for upload into staging tables

I am using the following query to extract id numbers for inserting data, there is over 2000.
I need to extract to a populate to an excel report or export to exel the sql results.
how do you do it? I have tried saving it file but it is a sql file or crystal reports.

Who is Participating?

Looking at your query again, if using a procedure directly doesn't work, you might also want to consider inserting your results into a temp table, then calling a select from that temp table after the while loop has completed.

Or just google it, there's a million sites which describe how to. Once added, you can find the connection under the Data tab in Excel, selecting "From other sources", and the "Microsoft Query". Select your ODBC data source to get started. (For more details on how to create a query, see further below after the part which describes how to add an SQL driver connection instead of ODBC).

Alternatively you can use the SQL driver inside MS Excel so that you don't need the ODBC connection on the computer. To do this, in Excel go to the Data tab, then select "From other sources", then select "From Microsoft query".
Under Databases, select New data source". Give the data source a name (eg. the database you're connecting to). I believe this should be SQL Server, but it might be SQL native client or native client 10. Not entirely sure here.
After that, click the "connect" button. Select the server you wish to connect to. If you use Windows authentication you can select "use trusted connection". If not, untick and enter your SQL username and password. Go to "Options" before you click on OK to select the default database and, if required, language.
Under step 4 of the create new data source screen you can select a default table if you like, but this is usually not needed.
If you use SQL authentication you can choose to "save my user ID and password in the data source definition". This is however NOT recommended, as this stores your credentials unencripted in the connection string!
Once all is filled, press OK. Now you can select your new data source. Select OK. You can now use the query wizard to create your query or, my preferred way, click "cancel" and then say "yes" when asked if you want to continue to edit this query in Microsoft query.
Just close the "add tables" window that pops up and click on the SQL button in the MS Query taskbar to write a query. You can copy/paste your query here, or if you changed it to a stored procedure type {Call "yourstoredprocedure"} including the opening and closing bracket.
If you set everything up correctly you should see the data appear in your screen. Once you click on the exit button (open door with arrow) Excel will ask you where to put the data in your Excel sheet.
Rigth clicking on the table should allow you to refresh the data again.

Or just google it, there's a million sites which describe how to. Once added, you can find the connection under the Data tab in Excel, selecting "From other sources", and the "Microsoft Query". Select your ODBC data source to get started. (For more details on how to create a query, see further below after the part which describes how to add an SQL driver connection instead of ODBC).

Alternatively you can use the SQL driver inside MS Excel so that you don't need the ODBC connection on the computer. To do this, in Excel go to the Data tab, then select "From other sources", then select "From Microsoft query".
Under Databases, select New data source". Give the data source a name (eg. the database you're connecting to). I believe this should be SQL Server, but it might be SQL native client or native client 10. Not entirely sure here.
After that, click the "connect" button. Select the server you wish to connect to. If you use Windows authentication you can select "use trusted connection". If not, untick and enter your SQL username and password. Go to "Options" before you click on OK to select the default database and, if required, language.
Under step 4 of the create new data source screen you can select a default table if you like, but this is usually not needed.
If you use SQL authentication you can choose to "save my user ID and password in the data source definition". This is however NOT recommended, as this stores your credentials unencripted in the connection string!
Once all is filled, press OK. Now you can select your new data source. Select OK. You can now use the query wizard to create your query or, my preferred way, click "cancel" and then say "yes" when asked if you want to continue to edit this query in Microsoft query.
Just close the "add tables" window that pops up and click on the SQL button in the MS Query taskbar to write a query. You can copy/paste your query here, or if you changed it to a stored procedure type {Call "yourstoredprocedure"} including the opening and closing bracket.
If you set everything up correctly you should see the data appear in your screen. Once you click on the exit button (open door with arrow) Excel will ask you where to put the data in your Excel sheet.
Rigth clicking on the table should allow you to refresh the data again.

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Or just google it, there's a million sites which describe how to. Once added, you can find the connection under the Data tab in Excel, selecting "From other sources", and the "Microsoft Query". Select your ODBC data source to get started. (For more details on how to create a query, see further below after the part which describes how to add an SQL driver connection instead of ODBC).

Alternatively you can use the SQL driver inside MS Excel so that you don't need the ODBC connection on the computer. To do this, in Excel go to the Data tab, then select "From other sources", then select "From Microsoft query".
Under Databases, select New data source". Give the data source a name (eg. the database you're connecting to). I believe this should be SQL Server, but it might be SQL native client or native client 10. Not entirely sure here.
After that, click the "connect" button. Select the server you wish to connect to. If you use Windows authentication you can select "use trusted connection". If not, untick and enter your SQL username and password. Go to "Options" before you click on OK to select the default database and, if required, language.
Under step 4 of the create new data source screen you can select a default table if you like, but this is usually not needed.
If you use SQL authentication you can choose to "save my user ID and password in the data source definition". This is however NOT recommended, as this stores your credentials unencripted in the connection string!
Once all is filled, press OK. Now you can select your new data source. Select OK. You can now use the query wizard to create your query or, my preferred way, click "cancel" and then say "yes" when asked if you want to continue to edit this query in Microsoft query.
Just close the "add tables" window that pops up and click on the SQL button in the MS Query taskbar to write a query. You can copy/paste your query here, or if you changed it to a stored procedure type {Call "yourstoredprocedure"} including the opening and closing bracket.
If you set everything up correctly you should see the data appear in your screen. Once you click on the exit button (open door with arrow) Excel will ask you where to put the data in your Excel sheet.
Rigth clicking on the table should allow you to refresh the data again.

Hope this gets you started.

0

Amanda WalshawBusiness Solutions AnalsystAuthor Commented: 2013-05-21

thank you Kvwielink for taking the time out, but I am not getting the 100 qty I require the ms query via excel is only generating one result, please see attached document.
Where am I going wrong? Much appreciated on your advice so far.
Kind Regards, FlyFishUsing-exel-2010-got-connected-to.docx

Can you try and change the query to a stored procedure, then call the stored procedure in Excel instead? MS Query is limited in what it can handle, and I suspect this command might already be too complex. If you call the procedure ABCD for instance, the syntax would be: