print out (hard copy) automatically whenever an insert occurs on a specific table

  • hallo I need to print out (hard copy) automatically whenever an insert occurs on a specific table(MSSQL2005).

    Hence I'd think I could make use of a trigger or something similar.

    Could you point me to any resource?

    Thanks in advance

  • Instead of a trigger, I'd put a flag column in the table, "IsPrinted" or some such name, and default it to 0. Then set up a job that runs every few minutes, or every minute, or every hour, depending on how often someone is going to check the printer, and have that print out what you need, then update the flags.

    Part of the reason for not putting this in a trigger is that, if the printer is out of paper, you could end up with a locked transaction till someone adds paper, and other, similar situations.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • oh! thank yous for quick reply..

    can you tell me the process/sample code

  • I guess it will probably depend on what output format you want. Are you simply printing a text file, or does it need to have some sort of formatting to it? Is it a data grid, or is it more like a letter/e-mail, or something else?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Hi,

    actually what i required is, when ever a record inserted into DB. then i required a print out that details(instered record) with some calculations.

  • You could probably accomplish that with SSIS pretty easily. Output the data and calculations to a file, and then copy the file to the printer port.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • thank you sqard,

    But wht is want it should done all automatically...

    can you give some link or code

    thanks in advance.

  • You have provided neither

    a) sample data, nor

    b) an example of what you want to print

    yet you are asking for sample code. Leaving aside paranormal abilities, just how do you expect people to do that?

    SSIS can do all of this automatically for you (maybe - I will know more if the sample data ever appears), so I suggest you should not make the assumption that it cannot when it appears that you have not even attempted to solve your own problem.

    And if you are going to quote someone's name, you should at least make an effort to spell it correctly. 'sqard' is just plain rude.


Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply