Hello,
I ran into a problem, where I am not sure how sql server is reacting -
There is a table dbo.T1 with columns (OWNER, DATA)- now I have 3 stored procs - dbo.Begin, dbo.Copy, dbo.END.
There is a process running which reads a file (file contains - OWNER and DATA) and calls these procs in the sequence dbo.Begin, dbo.Copy, dbo.END.
dbo.Begin proc deletes the data from dbo.T1 table where OWNER='X'
dbo.Copy proc copies the data to dbo.T1 table. (So this time all the existing data for this owner 'X' is deleted from the table T1)
dbo.END proc grabs the copied data from the table T1 and distribute in multiple tables.
Now my question is - if there is a file f1.txt placed so dbo.Begin will clear data from T1 table and after then dbo.Copy will start copying the data from f1.txt table dbo.T1. Now - if a new file f2.txt for the same Owner is placed - dbo.Begin will start clearing the data - but the problem is earlier execution of dbo.Copy is not yet finished. So this may be a problem and the 2nd instance of dbo.Begin might NOT delete all the data from table T1.
Please advice how this could be handles, I think SQL setver would take care of itself by having locks on the table T1, but not exactly sure how.
Any help is appreciated. Thanks
I ran into a problem, where I am not sure how sql server is reacting -
There is a table dbo.T1 with columns (OWNER, DATA)- now I have 3 stored procs - dbo.Begin, dbo.Copy, dbo.END.
There is a process running which reads a file (file contains - OWNER and DATA) and calls these procs in the sequence dbo.Begin, dbo.Copy, dbo.END.
dbo.Begin proc deletes the data from dbo.T1 table where OWNER='X'
dbo.Copy proc copies the data to dbo.T1 table. (So this time all the existing data for this owner 'X' is deleted from the table T1)
dbo.END proc grabs the copied data from the table T1 and distribute in multiple tables.
Now my question is - if there is a file f1.txt placed so dbo.Begin will clear data from T1 table and after then dbo.Copy will start copying the data from f1.txt table dbo.T1. Now - if a new file f2.txt for the same Owner is placed - dbo.Begin will start clearing the data - but the problem is earlier execution of dbo.Copy is not yet finished. So this may be a problem and the 2nd instance of dbo.Begin might NOT delete all the data from table T1.
Please advice how this could be handles, I think SQL setver would take care of itself by having locks on the table T1, but not exactly sure how.
Any help is appreciated. Thanks
Comment