sql Raiserror with parameters

/ Published in: SQL
Save to your folder(s)

You can see details on http://msdn.microsoft.com/en-us/library/ms178592.aspx , but I try to explain how you throw error with "uniqueidentifier" type parameters.

I convert uniqueidentifier to string (nvarchar(50)) and set a variable.
"%s" is equal to "string"

Copy this code and paste it in your HTML
  1. DECLARE @raiseErrorCode nvarchar(50)
  2. SET @raiseErrorCode = CONVERT(nvarchar(50), YOUR UNIQUEIDENTIFIER KEY)
  3. RAISERROR('%s INVALID ID. There is no record in table',16,1, @raiseErrorCode)

URL: http://msdn.microsoft.com/en-us/library/ms178592.aspx

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.