February 1, 2012 at 1:16 pm
We recently migrate a database from SQL server 2005 to 2008.
There are some stored procedures in it, when developers trying to udpate the stored procedure, she got errors like below:
dropping procedure [AllocationAdjustStaffSelect]...
creating procedure [AllocationAdjustStaffSelect]...
Msg 2778, Level 16, State 1, Procedure spot_AllocationAdjustStaffSelect, Line 107
Only System Administrator can specify WITH LOG option for RAISERROR command.
Msg 15151, Level 16, State 1, Line 2
Cannot find the object 'AllocationAdjustStaffSelect', because it does not exist or you do not have permission.
I checked in the stored procedure, there are some code like this:
-- Exit Handler
ExitHandler:
IF @iError <> 0
BEGIN
RAISERROR(@sMessage,11,1) WITH LOG, NOWAIT
RETURN -1
END
RETURN 0
END
SET NOCOUNT OFF
GO
I don't want to give the developer system admin permission, but how can we fix the error?
Thanks
February 1, 2012 at 1:27 pm
Give the User
alter trace permissions
LOG
Logs the error in the error log and the application log for the instance of the Microsoft SQL Server Database Engine. Errors logged in the error log are currently limited to a maximum of 440 bytes. Only a member of the sysadmin fixed server role or a user with ALTER TRACE permissions can specify WITH LOG.
February 1, 2012 at 1:39 pm
A user with ALTER TRACE permission can also use the WITH LOG.
February 1, 2012 at 1:53 pm
Thanks all
February 1, 2012 at 11:08 pm
:w00t:
Hello i suggest you to use Using TRY...CATCH in Transact-SQL to avoid any undesired results
show below link
http://msdn.microsoft.com/en-us/library/ms179296.aspx
:hehe:
February 1, 2012 at 11:51 pm
Take control over your proprietary error codes and declare your own messages ( and alerts if needed )
Have a look at sp_addmessage in BOL:
exec sp_addmessage [ @msgnum = ] msg_id , [ @severity = ] severity , [ @msgtext = ] 'msg'
[ , [ @lang = ] 'language' ]
[ , [ @with_log = ] { 'TRUE' | 'FALSE' } ]
[ , [ @replace = ] 'replace' ]
and then of course use :
RAISERROR(yourmsg_id [, paramx,..])
No more the need to specify "with log" because the message has been declared "with log"
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
February 5, 2012 at 2:54 pm
johnitech.itech (2/1/2012)
:w00t:Hello i suggest you to use Using TRY...CATCH in Transact-SQL to avoid any undesired results
show below link
http://msdn.microsoft.com/en-us/library/ms179296.aspx
:hehe:
That's not likely to help with the privs necessary to write an error message to the SQL Server Log... especially if the error being caused is actually in the TRY/CATCH when they reraise the error that caused the problem in the first place.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 5, 2012 at 2:58 pm
ALZDBA (2/1/2012)
Take control over your proprietary error codes and declare your own messages ( and alerts if needed )Have a look at sp_addmessage in BOL:
exec sp_addmessage [ @msgnum = ] msg_id , [ @severity = ] severity , [ @msgtext = ] 'msg'
[ , [ @lang = ] 'language' ]
[ , [ @with_log = ] { 'TRUE' | 'FALSE' } ]
[ , [ @replace = ] 'replace' ]
and then of course use :
RAISERROR(yourmsg_id [, paramx,..])
No more the need to specify "with log" because the message has been declared "with log"
Absolutely outstanding, Johan. I was looking for a way to get around all of that. You've saved me a bit of a headache. Thanks, ol' friend.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 5, 2012 at 11:51 pm
Always HTH.
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply