Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ostinoh
Yak Posting Veteran
66 Posts |
Posted - 2013-03-13 : 11:14:29
|
Hello - I created a Store Procedure to have Table A sync with Table B by doing an insert of the data that it does not have.The issue I'm running into is when I run the Stored Proc it's taking longer then just running the Insert itself. I want to put this into a Job to run at night but also to have it in a Transaction in case I need to rollback as well on an error. Can someone take a look to see if I have to much or not enough in my script?USE [Dev_SageReporting]GOSET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[hgsp_backloglaborb_sync]AS DECLARE @intErrorCode INTBEGIN TRANINSERT INTO BackLogLaborB SELECT * FROM BackLogLaborCurrent AS A WHERE NOT EXISTS ( SELECT * FROM BackLogLaborB AS B WHERE A.PIT = B.PIT ) SET NOCOUNT ON; SELECT @intErrorCode = @@ERRORIF ( @intErrorCode <> 0 ) ROLLBACK TRANSACTIONELSECOMMIT TRANSACTION [/code]Regards,David |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-13 : 11:17:41
|
might be due to a bad plan in cache. try flushing out the procedure cache and then executing it------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|