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 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Automtically printing results (using DTS)

Author  Topic 

malletts
Starting Member

16 Posts

Posted - 2004-03-19 : 13:08:42
Hi,

Does anyone know of a method to automatically print the result-set of a stored procedure directly to a default printer. I'm investigating using DTS to run some sql - export to a text file and then print this test file directly. I know that in Oracle SQL*Plus, there is a 'spool out' option which will spool files to a printer. Is there an equivalent T-SQL/DTS option or will I have to try and schedule a print-job via at/Task scheduler?

Thanks,

All help greatly appreciated.
Stephen

MuadDBA

628 Posts

Posted - 2004-03-19 : 17:18:39
How about

exec master..xp_cmdshell 'Print /D:[printer name] [text file name]'

works for me.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-03-19 : 17:41:03
That was what I was going to recommend. And don't put it into a DTS package. Export the data using bcp.exe, then run xp_cmdshell to print the file. You can call bcp.exe from xp_cmdshell as well. You can wrap them both up in a stored procedure and then schedule the stored procedure. Or have two jobs steps. One that is a cmdexec step that runs bcp.exe and another that runs the xp_cmdshell to print the document.

DTS is just too heavy for this type of thing.

Tara
Go to Top of Page
   

- Advertisement -