Unix Technical Forum

Printing query results from sp

This is a discussion on Printing query results from sp within the SQL Server forums, part of the Microsoft SQL Server category; --> Is there any way to send the results of a query executed within a stored procedure to the default ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 08:48 AM
Par-breaker
 
Posts: n/a
Default Printing query results from sp

Is there any way to send the results of a query executed within a stored
procedure to the default windows printer, or even to a text file? (I
thinking of something similar to Oracle's DBMS_OUTPUT, or UTL_FILE
commands.)?

I want the query to run unattended, but send the results directly to the
printer.

Thanks


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 08:48 AM
Chandra
 
Posts: n/a
Default Re: Printing query results from sp

Hi

to copy the result to a flat-file, u can use this:

declare @str varchar(255)
SET @str = 'isql -Q"select * from <tablename>" -E -oc:\file.fil'
exec master..xp_cmdshell @str


best Regards,
Chandra
http://groups.msn.com/SQLResource/
http://chanduas.blogspot.com/
---------------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 08:48 AM
Simon Hayes
 
Posts: n/a
Default Re: Printing query results from sp

There's no easy way to send the results to a printer, but you can use
osql.exe or bcp.exe to get the results of a query into a text file -
see Books Online for the details. You could then send the text file to
a printer with an external script of some sort.

Simon

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 08:48 AM
TLetsek
 
Posts: n/a
Default Re: Printing query results from sp

Thanks Chandra and Simon...
Guess I'll set up a job to run an external app that can query the data and
send the results
to the printer.



"Par-breaker" <tkestell@comcast.net> wrote in message
news:taudnRQdI_L7WALfRVn-iw@comcast.com...
> Is there any way to send the results of a query executed within a stored
> procedure to the default windows printer, or even to a text file? (I
> thinking of something similar to Oracle's DBMS_OUTPUT, or UTL_FILE
> commands.)?
>
> I want the query to run unattended, but send the results directly to the
> printer.
>
> Thanks
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:54 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com