September 20, 2017 at 2:35 am
Hi, Guys i try to delete large data from my db about 1.5 mln rows ( 2012 Sql server), actually i delete this rows but strange i have completed with errors.I think is something wrong with script.Thank you
September 20, 2017 at 2:41 am
What are the errors you receive? We can't run your SQL and we don't have access to your data, server or environment, so I'm afraid only supplying your SQL doesn't really help us help you troubleshoot.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
September 20, 2017 at 3:07 am
This script delete data , but when finish message is Query Completed with errors., i think the problem is in this logic
The problem is i need to insert hude data in variable table where Id is clustered, which is gonna be deleted, but in this rows.I have to skip ids which have reference to another table.
September 20, 2017 at 3:14 am
ndoee - Wednesday, September 20, 2017 3:07 AMThis script delete data , but when finish message is Query Completed with errors., i think the problem is in this logic
Yes, but what ARE the errors? If, for example, you're running the query in SSMS then the errors will be presented in Messages Pane of your Results window.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
September 20, 2017 at 4:00 am
I get it man i didnt see it because i hit some rows where have reference to another table.So the statement has been terminated, but the rows is delete it 🙂
September 20, 2017 at 4:09 am
ndoee - Wednesday, September 20, 2017 4:00 AMI get it man i didnt see it because i hit some rows where have reference to another table.So the statement has been terminated, but the rows is delete it 🙂
Ahh, I assume that there's some kind of foreign key pointing to your table, and as a result you can't delete the rows. You'll need to delete the rows in the child table (that are related to row you're going to delete in your parent) before deleting the rows in the parent.
Edit: Poor wording, could have been read as if I was saying the child table needs to be emptied, rather than only the relevant rows need to be deleted. Oops! :hehe:
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
September 20, 2017 at 5:20 am
Actually i take 50 rows in batch and when i see reference rollback but script dosnt stop move forward take another 50 and again and again, for now from 1.5 mln for 2 minutus i have 32 k when i add small number for batch like 1 ROW, query need 15 min but its good i have 5 k rows which have reference, anyway bro Thank you 🙂
September 22, 2017 at 7:41 pm
If you are deleting the majority of the table, you may find it more performant to copy the records to DO want to a new (temp) table and then truncate the full table and insert the saved records back into it. Make sure you wrapt this all in a transaction in case it goes wrong.
September 25, 2017 at 8:42 am
aaron.reese - Friday, September 22, 2017 7:41 PMIf you are deleting the majority of the table, you may find it more performant to copy the records to DO want to a new (temp) table and then truncate the full table and insert the saved records back into it. Make sure you wrapt this all in a transaction in case it goes wrong.
+1 to that. I would be more inclined to choose this method rather than such a large fully logged delete.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply