July 26, 2011 at 11:32 am
I'm running something like this:
more:
waitfor delay '00:00:05'
insert top (1000) into TableB Select *
from TableA A where A.ID not in (select ID from TableB) -- not already inserted
if @@rowcount > 0 goto more
Assuming there are 100,000 records to be inserted (100 loops), should I expect to get a result when it's halfway through if I run:
select count(*) from TableB with (nolock)
Or will my count be 0 until it completes ?
Update: I cancelled the insert, modified some code, and now it seems to be working .... basically: inefficient code.
July 26, 2011 at 11:39 am
You'll see it as it inserts.
Not 100% sure you'll get any numbers like 16472 instead of multiples of 1000. But that might be a fun test to setup.
Care to do it and post the results?
July 26, 2011 at 11:48 am
It's been running 2 hours and I get 0 🙁
July 26, 2011 at 11:53 am
homebrew01 (7/26/2011)
It's been running 2 hours and I get 0 🙁
What is it waiting on? (sp_WhoIsActive)
July 26, 2011 at 11:58 am
I have a process to alert me if there's blocking, but no problems so far.
July 26, 2011 at 12:03 pm
Don't know what to tell you. I've definitely done this in the past and I was getting ever increasing counts in the table. I don't know what could be the difference (except that you're looking in the wrong table but I don't dare to suggest that option :w00t:)
July 26, 2011 at 12:15 pm
Ninja's_RGR'us (7/26/2011)
Don't know what to tell you. I've definitely done this in the past and I was getting ever increasing counts in the table. I don't know what could be the difference (except that you're looking in the wrong table but I don't dare to suggest that option :w00t:)
I thought I've done it in the past too .... I'm checking the right table .... could be some other brain fart going on with the where clause.
July 26, 2011 at 12:39 pm
Update: I cancelled the insert, modified some code, and now it seems to be working .... basically: inefficient code.
July 26, 2011 at 12:48 pm
Happy to almost have helped :hehe:.
July 26, 2011 at 1:03 pm
Thanks 🙂
April 23, 2013 at 7:28 am
Can you please share that modified code or share what you have changed!!!!!!!!!
Thanks
April 23, 2013 at 11:00 am
Almost 2 years ago at a different company. I don't remember. But since I only displayed sample code, not sure how it would help you.
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply