Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 409
  • Last Modified:

Printing from SQL stored procedure or trigger

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
BoydMoon
Asked:
BoydMoon
  • 3
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>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
 
BoydMoonAuthor Commented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
BoydMoonAuthor Commented:
Answer was not very specific regarding syntax
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
<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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now