Questions tagged [raiserror]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
51 views

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, ...
0
votes
0answers
32 views

SQL Throw with TableErrorLog

I read Raiserror is being deprecated in SQL Server, our team uses an error log table. How would I change our previous code to utilize throw? I want to learn the appropriate modification for legacy ...
0
votes
3answers
132 views

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, ...
0
votes
2answers
862 views

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 ...
0
votes
0answers
362 views

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 = ...
0
votes
1answer
217 views

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 ...
2
votes
1answer
341 views

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 ...
4
votes
2answers
3k views

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 ...
0
votes
0answers
111 views

The best way to raise error from mass insert query

I have a following stored procedure: CREATE TABLE Table1 (val INT) GO CREATE TABLE Table2 (val INT) GO ALTER TABLE Table1 ADD CONSTRAINT chk1 CHECK (val > 0 ) GO INSERT INTO Table2 SELECT 1 UNION ...
2
votes
1answer
2k views

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 ...
0
votes
1answer
97 views

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($...
1
vote
1answer
16k views

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 ...
4
votes
1answer
3k views

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 '...
1
vote
1answer
398 views

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 ...
0
votes
0answers
587 views

Oracle force job to fail via raise_application_error

I have a business-flow consisting of several steps implemented as stored procedures in Oracle. I want wrap the whole flow, which is linear (Step1 -> Step2 -> Step3 ->...) into a job that will run ...
6
votes
4answers
7k views

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); ...
0
votes
1answer
5k views

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 ...
1
vote
0answers
95 views

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 ...
4
votes
1answer
1k views

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 ...
3
votes
1answer
2k views

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. ...