[T-SQL] try/catch not taking catch path |
try/catch not taking catch path Posted: 08 Aug 2013 09:00 AM PDT if you have the following code (where temptable does not exist):[code]BEGIN TRANBEGIN TRY PRINT 'Before bad insert' INSERT temptable VALUES ( 1, 2, 3 ) PRINT 'After bad insert' COMMIT TRANEND TRYBEGIN CATCH PRINT 'Inside CATCH before ROLLBACK' ROLLBACK TRAN PRINT 'Inside CATCH after ROLLBACK'END CATCH [/code]I get the following in my query message window:Before bad insertMsg 208, Level 16, State 1, Line 4Invalid object name 'temptable'.Why doesn't it take the Catch condition?Thanks,Tom |
Posted: 08 Aug 2013 09:17 PM PDT Hi all I am tasked with importing large fixed width text file to SQL, previously I used a library called filehelpers to assist through my code. Now the files are growing I keep getting out of memory errors so decided to try BCP.My command bcp SLADB.dbo.AlarmDetTB format nul -T -n -f ProdData-n.fmtand the result SQLState = 08001, NativeError = 2Error = [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: tt open a connection to SQL Server [2].SQLState = 08001, NativeError = 2Error = [Microsoft][SQL Server Native Client 10.0]A network-related or specific error has occurred while establishing a connection to SQL Server is not found or not accessible. Check if instance name is correct and Server is configured to allow remote connections. For more information server Books Online.SQLState = S1T00, NativeError = 0Error = [Microsoft][SQL Server Native Client 10.0]Login timeout expiredThis is a localhost server with windows authPlease help me learn why, I have tried with the -t switch and same result |
try/catch not taking catch path Posted: 08 Aug 2013 09:00 AM PDT if you have the following code (where temptable does not exist):[code]BEGIN TRANBEGIN TRY PRINT 'Before bad insert' INSERT temptable VALUES ( 1, 2, 3 ) PRINT 'After bad insert' COMMIT TRANEND TRYBEGIN CATCH PRINT 'Inside CATCH before ROLLBACK' ROLLBACK TRAN PRINT 'Inside CATCH after ROLLBACK'END CATCH [/code]I get the following in my query message window:Before bad insertMsg 208, Level 16, State 1, Line 4Invalid object name 'temptable'.Why doesn't it take the Catch condition?Thanks,Tom |
You are subscribed to email updates from SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8) To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment