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)
 Raiserror w/log

Author  Topic 

jimmyjoemeeker
Starting Member

6 Posts

Posted - 2007-09-30 : 21:45:47
Can't get this to work. I've read you're suppose to pass a parameter @with_log set to true.

Raiserror('test', 1, 18) @with_log

The problem is I can't get the syntax correct and I can't find any info on the syntax. Any help would be greatly appreciated.

thanks

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-09-30 : 22:07:08
the syntax is like this:

RAISERROR('test', 1, 18) WITH LOG


elsasoft.org
Go to Top of Page

jimmyjoemeeker
Starting Member

6 Posts

Posted - 2007-10-01 : 14:00:12
This works fine for tht sql log, but I've read that this should write it to the windows log also. I can't get that to work which indicates to me that it won't write to the windows app log. Any info on this?

thanks....
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-01 : 14:29:02
Perhaps you are referring to using a severity level from 19 to 25 - but that will abort the application and has some permission requirements, and probably some other significant side effects ...

Kristen
Go to Top of Page

tm
Posting Yak Master

160 Posts

Posted - 2007-10-01 : 14:29:28
I believe you may be looking for xp_logevent (Transact-SQL)

I have tested the example below and it writes to Windows application event.

Refer to Books on line for documentation as you must have permission to run xp_logevent as this is an extended SP in Master DB:

DECLARE @@TABNAME varchar(30)
DECLARE @@USERNAME varchar(30)
DECLARE @@MESSAGE varchar(255)
SET @@TABNAME = 'customers'
SET @@USERNAME = USER_NAME()
SELECT @@MESSAGE = 'The table ' + @@TABNAME + ' is not owned by the user
' + @@USERNAME + '.'

USE master
EXEC xp_logevent 60000, @@MESSAGE, informational



quote:
Originally posted by jimmyjoemeeker

This works fine for tht sql log, but I've read that this should write it to the windows log also. I can't get that to work which indicates to me that it won't write to the windows app log. Any info on this?

thanks....

Go to Top of Page

jimmyjoemeeker
Starting Member

6 Posts

Posted - 2007-10-01 : 15:53:24
Worked fine. Thank you....
Go to Top of Page
   

- Advertisement -