Thursday, June 30, 2011

SQL To Find Records That Do Not Have Association

SQL Server Query to determine specific records that do not have a specific association to them:

select distinct documentid, ownername from contenttextpub where documentid in (select distinct documentid from contenttext where contentid in (Select contentid from contentsecuritytag where tagid=(select recordid from tag where referencekey='NULLTAG')))

Feels like recursion, but its more tied to the SQL Query grammer and how the SQL Server interpreter parses the query to get the final query results.

No comments: