Questions tagged [error-handling]
The error-handling tag has no summary.
153 questions
0
votes
0
answers
73
views
Temp Table Management in Explicit Transactions and CATCH blocks
Example code below populates a PhoneNumber table and associates those PhoneNumberId's with an OrderNumber.
As written I am getting the error message:
The current transaction cannot be committed and ...
5
votes
1
answer
422
views
What is a good way to handle an error while parsing a T-SQL command that doesn't exist on an older version of SQL Server?
I am trying to grant the [CONNECT ANY DATABASE] permission to a specific SQL account on multiple instances. However, one server is running SQL Server 2012 and that permission was not introduced until ...
2
votes
1
answer
291
views
RAISERROR / THROW and sp_start_job Termination Behaviour
Given the following SQL Server Agent job
USE [msdb]
GO
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[...
0
votes
1
answer
129
views
How to get detailed error messages. Include table & column names & records. Conversion failed when converting the varchar value 'A' to data type int
I have an old, large (more than 140 lines), and complicated SQL query. It is joining many tables and has detailed WHERE conditions with values and a detailed GROUP BY part.
Query Structure
SELECT
...
0
votes
1
answer
52
views
Passing contextual information to Postgres statements
To improve our insights on the health of some of our services, we've decided to improve our logging practices.
One thing I've always wanted to explore was whether it's possible to easily correlate a ...
0
votes
2
answers
149
views
Performance issue - using try catch to return data to service & how to use partition table with unique index
I'm working on enviorment SQL azure.
I've got a stored procedure that runs from several AKS simultaneously
and insert a message.
So it's a race for who writes the message first and the rest fails.
The ...
1
vote
1
answer
187
views
Does client timeout send the execution of a stored procedure from the TRY block to the CATCH block?
What happens when a client timeout occurs during the execution of a stored procedure that raises XACT_ABORT and wraps its body in TRY/CATCH blocks?
I am looking at a bunch of procedures that generally ...
0
votes
0
answers
135
views
Can I redirect rows on error in SSIS if the error happens within an "if condition", not while writing the column value?
I know how I redirect rows on error or truncation. That works if you have an error while you insert a value into the column.
Truncation: Say you have a string of 10 characters and you insert it into ...
2
votes
1
answer
2k
views
Catching exceptions and rolling back transactions
I am just trying to see if I understand this correctly:
By default, any error occurring in a PL/pgSQL function aborts
execution of the function and the surrounding transaction
I have a procedure ...
0
votes
3
answers
139
views
How to exit the Azure SQL script to skip all remaining batches?
I have a Python script that glues together individual SQL scripts like: creating tables, creating views, creating functions, creating stored procedures... It produces the single installation SQL ...
0
votes
1
answer
1k
views
Error handling - stored procedure nested in another stored procedure
I've got a stored procedure that call another stored procedure.
And i sometime get an error :
System.Data.SqlClient.SqlError: The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
At ...
1
vote
1
answer
514
views
Handle partial failures in a transaction (commit selectively) in MSSQL
I am doing a batch update where I process records sequentially (User 1, User 2 etc). Each record has multiple update queries associated to it. I need to skip if there is a data issue for an individual ...
3
votes
1
answer
486
views
How to cause a SQL Server database integrity error
I have created a stored procedure that uses dbcc checkdb on all userdatabases, if there are any errors detected it then collates the errors and formulates a html table and sends an html email to ...
1
vote
1
answer
694
views
Lost connection to the database during COMMIT query: did the transaction succeed or not?
PROBLEM
I recently encountered the error 2013 in MySql (Lost connection to MySQL server during query) while executing the COMMIT statement for a transaction (the previous update statements succeeded). ...
0
votes
2
answers
2k
views
Try Catch w/Transaction and executing stored procedures
I need to create an error-handling method for a couple of Stored Procedures.
Proc1
CREATE PROCEDURE dbo.Proc1
AS
BEGIN TRY
BEGIN TRANSACTION
EXEC Proc2
INSERT INTO tableA (col1, col2) ...