Solved

Printing from SQL stored procedure or trigger

Posted on 2008-06-13
5
376 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 142

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 142

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 142

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SYbase 4 32
Unable to Uninstall Visual Studio 2015 7 27
SSRS Enable Remote Errors 4 26
Merge two rows in SQL 4 17
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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 to return specific rows and columns, with various degrees of sorting and limits in place.

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