Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 EXPORT QUERY TO EXCEL FOR SQL select

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2008-08-07 : 11:23:04
How to EXPORT QUERY TO EXCEL via select query.

Select * from Tab_myOrders where ord_key='34'

Thank you very much for the info.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-07 : 11:26:53
you mean export the result to Excel ?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-07 : 11:27:15
Use OPENROWSET or SSIS Export/import task

Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2008-08-07 : 13:07:30
Hello Visakh,

When used the following getting an error i am using sql 2005:

insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=C:\testing.xls;',
'SELECT * FROM [SheetName$]') select * from TAB_ccsNetPickLists where fieldlabelkey='lblsubject'



Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.

Thank you very much.

quote:
Originally posted by visakh16

Use OPENROWSET or SSIS Export/import task



Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-07 : 13:12:23
Go to your sql server's surface area configuration manager and select checkbox for OPENROWSET (bt default it will be disabled).
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-08-07 : 13:28:06
Why don't you use simple Import/Export Wizard.You can put your query over there as well.
Go to Top of Page
   

- Advertisement -