Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Cannot Update Table when Data exist??

$
0
0

Hi All,

I have encountered a wired scenario in recent times.

I am using SQL Server 2008.

In a database, I have been using a stored procedure to insert/update a table ,, stored procedure has several temp tables ( local , as #TempList1) and a Merge statement.

I used the same procedure during past 12 months to insert/update the same table, and it worked all well without any issues.

Two days ago I noticed, when I run the stored procedure, it shows "Executing Query" on the lower task bar, but it never finishes..

Then I cancelled the query execution, and Truncated the table, which Merge statement refereeing to in the Stored Procedure.

Then when I re-run the stored procedure, it worked all well, inserted desired rows into the table.

###### Only issue I can think of what I did two days ago is: I copied the same stored procedure into another database on the same server and given a different stored procedure name, and changed the merge to insert/update table name in this new database.

Now the same issue comes up when I run the stored procedure in this new database, when table is not empty ,it keeps on running ,  and if I truncate the table and run the stored procedure , it work well..

Something gone wrong some where???

Appreciate if you'll can help please, I have over a million rows in the table, so I think it is not healthy task to truncate every time and run the procedure...

Cheers

Mira


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>