Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RE: Syntax Help

Status
Not open for further replies.

allyne

MIS
Feb 9, 2001
410
0
0
US
Hi everyone,

How can I export the result of this qry to an excel spreadsheet template on H:\Test.xls within a stored procedure. Would Like to have this in a stored procedure and not a DTS package.

Select AccountNumber,Name,Address
FROM TEMP
WHERE Left(Type,11) = 'Printed'

Thanks for your help!
 
The only way I can think to do this is to use xp_cmdshell and osql to create an output file on you hard drive...

something like

exec master.dbo.xp_cmdshell 'osql -E -Q"select name from sysobjects where type=''u''" -oc:\output.txt'

note -E = trusted connection -o = output file

all parameters are case sensitive.


HTH

Rob
 
You could try using Excel automation with sp_OACreate etc.

JHall
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top