?
Solved

Printing from SQL stored procedure or trigger

Posted on 2008-06-13
5
Medium Priority
?
390 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 750 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Suggested Courses

752 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