The tag has no usage guidance.

learn more… | top users | synonyms

2
votes
1answer
67 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 ...
2
votes
2answers
159 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
30 views

The best way to raise error from mass insert query

I have a following sproc: 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 ALL SELECT ...
0
votes
1answer
47 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
57 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 ...
0
votes
1answer
2k 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 ...
1
vote
1answer
727 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 ...
0
votes
1answer
109 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
175 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 ...
1
vote
3answers
2k 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
143 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, ...
1
vote
0answers
53 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 ...
3
votes
1answer
489 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 ...
3
votes
1answer
1k 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. ...