September 20, 2012 at 1:02 pm
Please tell me where the results of a print statement can be retrieved when the print statement is executed by a trigger.
Thx. Jean
September 20, 2012 at 1:04 pm
The bit bucket? I don't think the PRINT statement will actually print any where, but I could be wrong.
September 20, 2012 at 1:11 pm
jean 93062 (9/20/2012)
Please tell me where the results of a print statement can be retrieved when the print statement is executed by a trigger.Thx. Jean
if you are running a command in SSMS, it will show up in the messages window;
if you are running an applicaiton, it's probably not available to you unless you did some extra stuff to capture the InfoMessages of the Connection object (i.e. in vb.net AddHandler connection.InfoMessage, New SqlInfoMessageEventHandler(AddressOf OnInfoMessage) on the SqlConnection )
If you are a programmer,I can giet you an enhanced version of the Microsoft SQLHelper.vb class to expose that, it's pretty easy, but not quite as easy to use;
I was fiddling around with making an equivilent of the SSMS application so I know how it worked, and it's neat to divert stuff from messages to text to grid.
Lowell
September 20, 2012 at 1:12 pm
I was reading about this and I think the print statement actually does go somewhere. Another developer recommended that the Print statement be used instead of returning a results set.
September 20, 2012 at 1:22 pm
jean 93062 (9/20/2012)
I was reading about this and I think the print statement actually does go somewhere. Another developer recommended that the Print statement be used instead of returning a results set.
technically it's available to connections that have an event that is handling the SQLConnection.onInfomessage.
most connections don't bother; if your developers are using code that does myConn=New SQLConnection(), they are not handling it specifically, so it would be unavailable.
so if you are not specifically coding fo rit, it's not available...it goes into a null/black hole.
It's a variation of the tree falling in the woods kind of thing...if you don't put on your ears, you won't hear it.
Lowell
September 20, 2012 at 2:43 pm
Thank you. I'll consider the issue closed. In this case I did not write the application so I cannot capture the results. I will generate an entry into a log file to track the activity. Appreciate the help.
September 20, 2012 at 3:27 pm
jean 93062 (9/20/2012)
Thank you. I'll consider the issue closed. In this case I did not write the application so I cannot capture the results. I will generate an entry into a log file to track the activity. Appreciate the help.
PRINT will not return a result set to the GUI. Only SELECT will.
BTW, doing either in a trigger is usually a pretty bad idea. The return from the trigger can easily be mistaken by the App as an error being returned.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply