Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 view table while inserting

Author  Topic 

jamie
Aged Yak Warrior

542 Posts

Posted - 2008-09-16 : 10:50:30
hi,
If I run an insert query which inserts 10,000 records, then switch to another query and run a select count(*) from table I am inserting into. I have to wait until the insert has finished before my count is returned.
Is there a way to overcome this problem ?
This is not a problem in oracle..

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-16 : 10:52:46
you can use WITH NOLOCK to get results while insertion is happening.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-16 : 10:52:48
Yes, but it is not reliable.

SELECT COUNT(*) FROM TargetColumn WITH (NOLOCK)



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-09-16 : 10:53:44
You can see in table properties -Rows. But that won't be exact though.
Go to Top of Page

jamie
Aged Yak Warrior

542 Posts

Posted - 2008-09-16 : 11:15:48
ok,thank you.
Go to Top of Page

bjoerns
Posting Yak Master

154 Posts

Posted - 2008-09-16 : 11:43:17
I wonder why you'd like to retrieve a value for count(*) which is neither correct before nor after the insert?

If there's 10,000 rows there before and 20,000 after insertion, what's the point in getting a 13804 or something?


Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-16 : 21:45:47
maybe OP wants to show the progress ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Jason100
Starting Member

34 Posts

Posted - 2008-09-16 : 21:54:53
Maybe you can achieve info with:

Select count(*) from table(nolock)
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-16 : 22:05:17
that's what visakh and peso suggested


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-16 : 23:48:54
quote:
Originally posted by Jason100

Maybe you can achieve info with:

Select count(*) from table(nolock)


Do you read other suggestions before posting?
Go to Top of Page
   

- Advertisement -