error-handling's questions - English 1answer

98 error-handling questions.

I am working on sql script and I am having a requirement of stop continuing the script if some conditions are not satisfied. When I Google it, I found the RaisError with 20 severity level will ...

I am writing a simple MySQL Stored Procedure, and calling it from PHP using PDO. This is just simple enough to illustrate the problem I'm having. CREATE PROCEDURE `test_procedure_1`() BEGIN ...

I am collecting errors data using the error_reported event and saving the data on XEL files. The problem is that there are hundreds of thousands of errors over there and querying them can take a lot ...

We have a stored procedure that does some work within a transaction, wrapped within a stored procedure that returns some result data using the INSERT-EXEC method of sharing data. After observing the ...

I'm troubleshooting an issue on SQL Server 2000 where it appears that a update statement in a stored procedure failed, and the check for @@ERROR <> 0 didn't catch it, so the transaction was ...

TL;DR How can I diagnose the source of a very inconsistent, un-reproducable 'String or Binary data would be truncated.' error, when I am quite positive the problem isn't related to user data being to ...

If I want to write a message to the Postgres log I can do this: DO $$ BEGIN RAISE LOG 'Justin Is Awesome'; END $$; However, it logs the statement as well so I get 5 lines of output instead of one: ...

Before I restore a database, I need to save the contents of a table called dbo.ref_systemSettings if it exists. So I created a script that calls a procedure that will save the contents of this table ...

I have a job that sends an email to an operator (which contains a list of emails within it) upon complexion. Some of these people that are on that list are the developers who build everything in that ...

I'd like to use an ASSERT routine functionally similar to the one found in other languages, i.e. a construct (be it a procedure, syntax...) ASSERT( <condition>, <msg>) such that when the ...

Overview A package was developed due to a planned database server migration, and other teams with a dependency on legacy cross-database queries. There is a policy of not having Linked Servers, so an ...

I'm trying to get a master stored procedure to execute through to completion, where the master SP calls child SPs to perform modular tasks that are independent of each other (i.e. - if one fails, that ...

Which tools and programming libraries are you aware of that can help accelerate CSV manual correction process when column separator characters are encountered within data elements? I'm currently not ...

I like to be verbose in my coding, so my typical insert statement looks like this: INSERT INTO MyTable ( Column1 ,Column2 ,Column3 ,Column4 ,Column5 ,Column6 ) SELECT ...

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

Is there a trace configuration or setting that will enable the profiler to output ERROR_PROCEDURE() and ERROR_LINE() information that is always available when writing manual error handling in CATCH ...

I am trying to set an output param in a stored procedure, but I think that when I rollback the transaction I think I'm also rolling back the assignment to @out. Is that correct? If so, how can I ...

I have a code which does insert into destination table from source, but at times we are ending up with deadlocks. Due to deadlock , I have to rerun this code again. while i do re-run , I end up with ...

I have a table with several indexes. In my application code there could be instances where any of these indexes could be violated, depending on user input. I would like to log exactly which index was ...

I have a stored procedure that should return the below RAISERROR message when called. However, the text is appended to the message when returned: Transaction count after EXECUTE indicates a ...

I wonder how do I hook a certain database in SQL Server in a way that every error that is being thrown, and no one catches, will be caught and saved into an error_table in my database. Thanks.

Microsoft SQL Server has what I consider a remarkably sensible function, try_cast() which returns a null if the cast is unsuccessful, rather than raising an error. This makes it possible to then use ...

DESCRIPTION: SSPI handshake failed with error code 0x8009030c, state 14 while establishing a connection with integrated security; the connection has been closed. Reason: AcceptSecurityContext ...

I have a stored procedure which calls 2 nested sub procedures. For Example, MyProc BEGIN BEGIN TRY BEGIN TRAN EXEC UpdateProc EXEC InsertProc COMMIT TRAN END TRY ...

I have a trigger on a table (source) that data should be copied to the other one (target) in other database. I am trying to implement custom synchronization process for data: I want that target ...

I have an application that logs into SQL Server 2014 that uses a single login to access the database when a user opens up the application. In other words I have 6 users using the same application ...

I have encountered issues a few times when a process of mine performs a bulk load to a temp table we use for pre-processing purposes. The Bulk load fails for one reason or another (this we are looking ...

I have come across the following code (SQL Server 2016, 2008-compatible database): CREATE PROCEDURE myProc AS BEGIN DECLARE @ERRORMESSAGE As VARCHAR(1000) BEGIN TRY DELETE FROM ...

I have a select query that I use as part of an insert statement, but it raises the following exception: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value ...

I'm trying to query the ErrorLog files, but it sometimes fails on some of my servers. For some reason a file go missing from time to time. I do not know why. I do not think that I deleted the file :-)....

In SQL Server 2008 (but also in 2014). Let's consider a procedure that has an output parameter. This procedure may produce an error (and will in the following example). I note that the behaviour of ...

When I try below: backup database not_existing_db to disk = 'E:\Backup\not_existing_db.bak' SSMS shows two error messages: Msg 911, Level 16, State 11, Line 22 Database 'not_existing_db' does not ...

In pgAdmin3, via the SQL Editor, there is an Execute pgScript button which (unlike Execute Query) would run through the entire script, skipping errors. The SQL editor in pgAdmin4 doesn't appear have ...

I recently wrote a T-SQL script to perform some updates and inserts on 3 different tables. I wanted it done in a single transaction, so I read up on the Microsoft documentation on how to use explicit ...

The code below is a dynamic sql that will give you a list of all alerts in your system. It works. There is a temp table in the code for reasons beyond this question. This question is related to the ...

I need to catch errors in a transaction in a stored procedure and log them in a table in the catch block. After starting the transaction, a loop will attempt to insert a handful of values in the ...

I have a Access 2013 frontend linked to a 2014 SQL server. When users leave their workstation with their copy of the frontend open their computer will go often into sleep mode and lose their ODBC ...

Inserting multiple rows into a table with a single INSERT INTO statement fails (as expected) when some of these rows have values of a PostGIS geometry type incompatible to the respective row's PostGIS ...

When inserting multiple rows into a table by a single INSERT INTO invocation, and the INSERT statement fails due to reasons specific to some individual rows (e.g. a value has the wrong type for the ...

When issuing a backup command within a stored procedure that uses a try catch and dynamic sql, the error messages are very general when compared to running the backup command directly. Try/Catch ...

I need to know if the T-SQL below is correct to roll back if something bad happens. I first create a temp table IF OBJECT_ID(N'tempdb..#LocalSummary') IS NOT NULL DROP TABLE #LocalSummary ...

I am currently doing a merge on the following table between my test_db (target) and the same table on a different database called tablebackups (source). IF OBJECT_ID('[dbo].[tblBCatalogueType]') ...

basically I am looking for something like: before you can delete record x from my_table you need to: 1) delete x,y and z from table1 2) delete m and n from table2 3) delete a,b,c from table3 I ...

My goal is to catch errors from backup jobs into monitoring table. The problem is, that there are cases that backup statement returns more than one error, so ERROR_MESSAGE() is not enough: Msg ...

I've come across the abnormal situation, and can't understand what happens. I am connecting databases using PL/SQL Developer 8.0.4.1514(I've also tried v7,but same) . Sometimes(When I am trying to ...

I am trying to catch the error message when inserting records into a temp table from a stored procedure without rolling back everything. To illustrate, here is what I am trying to do: CREATE TABLE #...

It looks like XACT_ABORT ON is not working as expected. Here are a table and a procedure that inserts into it: CREATE TABLE rain ( rain_time DATETIME , location VARCHAR(100) ); GO ...

When writing procedures, I occasionally encounter situations in which I want to abort the procedure, even if the situation didn't necessarily trigger an error. Let's say, if I don't want John to be ...

I have an SSIS package in SQL Server 2014 which uses checkpoint to handle the cases where it needs to be run after a failure. There is a variable in the package that I want to be set to 0 whenever the ...

I have a procedure in MySQL that executes a handler for SQLEXCEPTION to read the errno code and insert it to a table. DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN GET DIAGNOSTICS CONDITION 1 @...

Related tags

Hot questions

Language

Popular Tags