Realtime record count for table...


here's little sql 2005 script i wrote:

1. start running script....

declare @x int

select @x = 1

while ( @x < 75000)
begin
 insert into  mytesttable  values (@x)
 select @x = @x + 1
end

 

2. while script still running, want know how many records in table. same query window script,  i have run both of following statements.

 

select count(*) mytesttable
witn (nolock)

select count(*) mytesttable
witn (tablock)

 

instead of getting the answer immediately, run after original script has completed. seem "blocked". how can near realtime count of number of records in table while script populates table?

 

thanks,

 

barkingdog

 

 

 

 

 

 

 barkingdog wrote:

yes, opening new window did enable to the "select count(*) ...."  run  why is case? (after all, i couldn't run "select  count(*) .."  from the window invoked original script. seems orignal script "blocks" conneciton need open new conneciton (window). why?

 

 

tia,

 

barkingdog

the query window runs statements sequentially , not run next statement until prior 1 has finished, select count(*)... not run until statements in the while loop complete.  it's not "blocking" connection, has not completed prior statements...

if one of replies solved problem, please mark them answered... 



SQL Server  >  Getting started with SQL Server



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607