Solved

Printing from SQL stored procedure or trigger

Posted on 2008-06-13
5
377 Views
Last Modified: 2010-04-21
I need to print to a log printer as a redundant fail-safe for a sports scoring application.  I would like to print the values of several fields each time an insert occurs.  I already have a trigger that fires on insert.  Is there a way to use xp_cmdshell to copy values to a printer port or to a printers IP address?

Thanks.
0
Comment
Question by:BoydMoon
  • 3
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21784829
>I would like to print the values of several fields each time an insert occurs.
does it have to be immediately?
  -> could it be "later"?

if you want to do this from the trigger, it will happen in the sql server box!
  -> is that what you want?
  -> can you print from the sql server anyhow?

>Is there a way to use xp_cmdshell to copy values to a printer port or to a printers IP address?
in short:
 if you can build a command line statement to print something to the printer, yes, you can call that from xp_cmdshell usually.
0
 

Author Comment

by:BoydMoon
ID: 21793820
Yes, as I stated in the question, I want to print when the insert occurs ... and printing from the SQL box is by design.  What I'm looking for is the command line syntax to do so.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 21794210
you can print a ascii file via the dos command line PRINT, or via the notepad using /P switch:
http://www.robvanderwoude.com/printfiles.html

so, all you need to do is to create that file first, and delete it afterwards...

note: to do that inside a trigger will take some time, and slow down the application.
0
 

Author Closing Comment

by:BoydMoon
ID: 31466987
Answer was not very specific regarding syntax
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21794347
<Grading Comments>
Answer was not very specific regarding syntax
</Grading Comments>

please note that you should not have closed the question, if you are unhappy with the details.
I would like to continue with the details, if you wish.
I posted the above link to give you the "options", and wanted to see if that fits you needs, in the first place.

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question