Groups | Blog | Home
all groups > dotnet ado.net > april 2007 >

dotnet ado.net : Quick seelct query record count


William (Bill) Vaughn
4/18/2007 5:23:35 PM
In a multiuser DBMS application, you can indeed check to see if an ID exists
but it won't guarantee that the ID will or will not exist a millisecond
later as others add and remove rows in the target table(s).

SELECT IDWanted FROM MyTable WHERE ID = IDWanted

What problem are you trying to solve?

--
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest books:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition) and
Hitchhiker's Guide to SQL Server 2005 Compact Edition

-----------------------------------------------------------------------------------------------------------------------
[quoted text, click to view]

Spam Catcher
4/19/2007 12:00:00 AM
"John" <John@nospam.infovis.co.uk> wrote in news:u$r57ohgHHA.4892
@TK2MSFTNGP03.phx.gbl:

[quoted text, click to view]

I would use a join or subselect query to move the data from one table to
another. Checking each row and copying can be very very slow if a large
Göran_Andersson
4/19/2007 12:00:00 AM
[quoted text, click to view]

Make an insert from a select, make a left join in the select against the
destination table and make a condition so that the select only returns
anything if the record doesn't exist in the destination table.

Example:

insert into Dest (A, B)
select s.A, s.B
from Source s
left join Dest d on d.SomeId = s.SomeId
where s.SomeField = Something and d.SomeId is null

--
Göran Andersson
_____
John
4/19/2007 1:06:58 AM
Hi

I need to check if a record exists (or not) in a table for a particular id.
Is there a quick way to do this (like ms access dlookup function or
similar)?

Thanks

Regards

John
4/19/2007 1:33:05 AM
Just need to copy records from one table to another but one at a time at
user request. So if the id (hence record) exists record is not copied
otherwise it is copied.

Thanks

Regards

[quoted text, click to view]

AddThis Social Bookmark Button