Solved

Printing from SQL stored procedure or trigger

Posted on 2008-06-13
5
374 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]
Comment Utility
>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
Comment Utility
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
Comment Utility
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
Comment Utility
Answer was not very specific regarding syntax
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
<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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now