Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 get SQLServer messages on C# vb or other language

Author  Topic 

asafg
Starting Member

39 Posts

Posted - 2009-05-25 : 06:57:30
I have a stored procedure with long executing time.

when I run it from within the management studio I can use the raise event - to check the progress (e.g: I'm working on step 2/10)

I need the sqlserver to return such string to C# or any other language.

Is it possible how

when I googled the subject I found someone that said that there is a error stream that should be a thread... Any ideas what he meant?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-25 : 07:00:34
Do a RAISERROR() with Severity 10 and WITH NO_WAIT option.
See http://weblogs.sqlteam.com/mladenp/archive/2007/10/01/SQL-Server-Notify-client-of-progress-in-a-long-running.aspx


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2009-05-25 : 07:01:04
The error stream will probably only be available when the query completes.
You could log the entries to a table then read them from the app?

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

asafg
Starting Member

39 Posts

Posted - 2009-05-26 : 09:17:35
Peso ...
from the sql side it works great...
RAISERROR('HELLO WORLD.', 12, 1) with nowait

the problem comes from the application side
the sql connection returns all the errors I raise but only a f t e r the execution is complete...
I need the application to read all the messages sent from the sqlserver - immediately when sent.

I fount in c# the command
FireInfoMessageEventOnUserErrors
but it doesnot seem to do any thing

Any ideas?
10x alot for the help

Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2009-05-26 : 09:20:49
lol - read my previous post.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2009-05-26 : 09:28:54
Actually there is a way to do this. Take a look at these links:

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlinfomessageeventhandler.aspx
http://geekswithblogs.net/mrnat/archive/2004/09/20/11431.aspx
http://social.msdn.microsoft.com/forums/en-US/sqlexpress/thread/369c1310-2602-4ae8-9d3a-dc3e605c8d81/


=================================================
Creating tomorrow's legacy systems today. One crisis at a time.
Go to Top of Page
   

- Advertisement -