Questions tagged [raiserror]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
-1 votes
1 answer

If RAISERROR is as good as deprecated, how are you supposed to flush the PRINT buffer?

RAISERROR is as good as deprecated. The documentation says New applications should use THROW instead of RAISERROR. Yet, it is commonly used to flush the PRINT buffer. Suppose that I'm writing a long ...
J. Mini's user avatar
  • 139
0 votes
0 answers

How to throw an error in SSDT Post-Deploy script to fail it's execution?

I'm using Microsoft SSDT to version DB schema. I have a script to autogenerate some triggers and i need to make sure that we don't forget to run it when tables change. I added a part to PostDeploy ...
Ivan Koshelev's user avatar
-2 votes
1 answer

Msg 2732, Level 16, State 1, Line 376039 Error number 515 is invalid. The number must be from 13000 through 2147483647 and it cannot be 50000 [closed]

Please help me how to solve it. why is it throwing this error as my script is inserting data into various tables extracted from an environment. #376039 is the catch block where rollback and other ...
Vikrant Singh's user avatar
0 votes
2 answers

Sql Server: Raise warnings and collect them

I need to raise one or more warning messages inside a child stored procedure and then collect all of them in the parent one. I tried with RAISERROR('Message 1',0,0) WITH NOWAIT but it doesn't work at ...
Radioleao's user avatar
  • 127
0 votes
2 answers

WHILE EXISTS Error Handling/ Raise Error

I am adding a step in my SQL job where it does a WHILE EXISTS check for me before executing the last step. What it does is it will wait for 15minutes to see if the table I am checking has been ...
WhoIsNotActive's user avatar
0 votes
1 answer

Distinguish errors I raise from other SQL Server errors

In my stored procedures, when a business rule is broken I raise an error that bubbles up to the C# client app and gets displayed to the user. e.g. RAISERROR('Hey, you cannot do that because blah blah ...
Craig's user avatar
  • 503
1 vote
1 answer

Error Severity 16 Alert being raised for events where is_event_logged = 0

I have an error level 16 alert set up as follows: USE [msdb] GO EXEC msdb.dbo.sp_add_alert @name=N'Error - Severity 16', @message_id=0, @severity=16, @enabled=1, @...
SE1986's user avatar
  • 1,960
0 votes
1 answer

SQL Server 2019: Rasing errors between 1 and 13000

I've been struggling with a task which requires me to raise a number of errors for testing purposes. Of course the time consuming errors are between 1 and 13000. I've managed to do them, but I need to ...
Fendder's user avatar
3 votes
1 answer

SSMS / SQL-Server delays console output (RAISEERROR WITH NOWAIT)

It is well known, that SSMS (or maybe the SQL Server, but I'd guess more the SSMS) delays PRINT messages until several lines (40) are gathered in the buffer, before they are really printed to the ...
Thomas Franz's user avatar
0 votes
1 answer

how to convert from raiserror to throw in the current context?

I have a function that checks is the file is present on disk in an specific location. Using that function I am checking for the latest backup, in the code below. If we don't have a backup anymore, ...
Marcello Miorelli's user avatar
0 votes
3 answers

Deprecated raiserror detection

I want to upgrade SQL server from 2008 to 2014 versiyon. I checked all of the deprecated features including raiserror syntax. But I have many stored procedures to check. Some of them use new syntax, ...
Banu Akkus's user avatar
6 votes
2 answers

raise an error in sql server severity higher than 18

I can easily raise user defined errors where severity is not higher than 18. When is higher, I get this error Error severity levels greater than 18 can only be specified by members of the ...
user avatar
0 votes
0 answers

SQL Server - What is the RAISERROR substitution parameter for boolean/bit type?

I'd like to quickly dump some context into an error message including some boolean flags using the handy-dandy substitution parameters of RAISERROR such as CREATE PROCEDURE MyProc ( @param1 INT = ...
Elaskanator's user avatar
0 votes
1 answer

How can I RAISE_APPLICATION_ERROR and do an INSERT in the same trigger?

From what I see, having the RAISE_APPLICATION_ERROR cancels the other operations that I would have in the trigger. I tried writing first the INSERT and then the RAISE_APPLICATION_ERROR hoping that ...
CCBet's user avatar
  • 115
2 votes
1 answer

Behavior of case sensitivity of RAISERROR when run remotely

I have a remote SQL Server that I can connect to using a local instance of SSMS. When raising errors, we use RAISERROR( 'This works', 16, -1 ) Remotely, this works fine if it's all uppercase, or ...
Brandon's user avatar
  • 151
6 votes
2 answers

How do I create a SQL Agent Alert on a custom error message in SQL Server 2012?

I want operators to be notified when I throw a custom error message. My understanding is that I need to add a message to sys.messages, then I can either RAISERROR or THROW that error ID. Creating an ...
Dan Bowling's user avatar
2 votes
1 answer

RAISERROR on a trigger. What will happen? Will we get informed?

What will happen if a trigger on a table hits the part of the trigger that includes the RAISERROR code below? RAISERROR('Attempt to modify supposedly immutable number.',16,1) How will we know this ...
chris's user avatar
  • 423
0 votes
1 answer

MySql Insert signal if where clause fails

As part of a chained sequence of transactional queries, I'm inserting values that exist in a temporary table into a new table. Every query is validated for errors in PHP using: if (!mysqli_query($...
helloworld's user avatar
1 vote
1 answer

Behaviour of RAISERROR within a TRY/CATCH within a loop

I have just encountered a section of SQL that is behaving not as I would expect (See below for a distilled version of the SQL in question that demonstrates the problem pattern). (This is on SQL ...
redcalx's user avatar
  • 383
11 votes
1 answer

How to conditionally raise an error in MySQL without stored procedure

I need to conditionally raise an error, but I can only use a simple statement and no stored procedure. I'd like to do something like this: select case when foo = "bar" then 1 else SIGNAL SQLSTATE '...
Gene Vincent's user avatar
2 votes
1 answer

Raising an Alert with THROW

It seems to me that SQL THROW is missing a crucial feature that RAISERROR has, and that is the abilty to use WITH LOG so that an Alert can be fired when the error number is logged in the Application ...
Christian McGhee's user avatar
15 votes
4 answers

How to escape '%' inside varchar @params for RAISERROR funcion in SQL Server 2012

How I should escape the % character in params so my RAISERROR retun my message declare @msg varchar(max) = (SELECT ' Message with % ' AS MSG) if @msg is not null begin RAISERROR (@msg ,16,1); ...
adopilot's user avatar
  • 2,423
0 votes
1 answer

RaiseError on SQL Server stored procedures

ALTER PROCEDURE sp1 as begin IF (@PersonId=0) RAISERROR(N'Error already raised. See previous errors.', 16, 1); break end I want something like the following. If no value in the variable, how ...
wit's user avatar
  • 1
2 votes
0 answers

What to do when the error message is longer than 4000 in T-SQL?

I have a OPENQUERY linking to an Oracle server that is failing. (I can't make any changes on the oracle server) But when it returns the error string it is cut short because it returns the query in ...
user802599's user avatar
4 votes
1 answer

Is it possible to return a custom error for a logon trigger?

I'm trying to get a logon trigger to return a custom error. Thus far everything I have tried causes it to return the standard error: My trigger looks like this: CREATE TRIGGER Test_Logon_Trigger ON ...
Kenneth Fisher's user avatar
2 votes
1 answer

Is it possible to raiserror within a For Delete Trigger that rolls back the deletes

There is a claim at the end of this accepted answer that if an error occurs within a "For Delete" trigger, the delete action would be rolled back because it is part of an implicit transaction. ...
crokusek's user avatar
  • 2,120