SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Convert a complex DCount to SQL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jimtimber
Starting Member

United Kingdom
49 Posts

Posted - 07/19/2014 :  11:07:59  Show Profile  Reply with Quote
Hi

I'm trying to convert the following Access DCount to something that will work with MS SQL. I believe it should be just a COUNT function but I can't get it to work. Any ideas please? Thank you :)

DCount("[FamiliesID]","[Tbl_Placements]","([DateOfPlacement] is not null) AND ([DatePlacementFinished] IS NULL) AND [Tbl_Placements]![FamiliesID] = " & [tbl_Families]![FamiliesID])

Jim

jimtimber
Starting Member

United Kingdom
49 Posts

Posted - 07/19/2014 :  11:10:23  Show Profile  Reply with Quote
(p.s. I only want those that are >0 from the above Access code, not sure if that needs to be built into code beforehand?)

Jim
Go to Top of Page

ScottPletcher
Constraint Violating Yak Guru

USA
381 Posts

Posted - 07/21/2014 :  13:16:58  Show Profile  Reply with Quote
Maybe?:


SELECT COUNT(*)
FROM Tbl_Placements tp
INNER JOIN Tbl_Families tf ON
    tf.FamiliesID = tp.FamiliesID
WHERE
    tp.FamiliesID > 0 AND
    DatePlacementFinished IS NULL

Go to Top of Page

jimtimber
Starting Member

United Kingdom
49 Posts

Posted - 07/22/2014 :  07:47:55  Show Profile  Reply with Quote
Hi Scott,

On its own, it works but i'll need to try it with other fields included in the same query. I'll let you know,

Thanks once again.

Jim
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000