G
Guest
I have a paramaterized command for a data adapter
SELECT MRN, Name, Sex, DOB, SSN
FROM dbo.Membership
WHERE (MRN = @MRN or @MRN is null)
AND (Name like @Name or @Name is null)
AND (Sex = @Sex or @Sex is null)
etc.
The name of that result set is from a stored procedure called:
qMembershipSelect
for 1.4 million records, this ensures that the data will come up quickly
because all I'm doing is filtering between 1-4 parameters.
But after the first select is done, I'd like to apply additional filtering
to that result set
that weeds out other stuff like duplicate records and selects a true Current
member:
SELECT DISTINCT MRN, MemNAME AS Member, DOB, SEX, SSN, GROUP, SGR,
[FROM-DT], [THRU-DT]
FROM qMembershipSelect AS Y
GROUP BY MRN, MemNAME, DOB, SEX, SSN, GROUP, SGR, [FROM-DT], [THRU-DT]
HAVING [THRU-DT] Is Null Or [THRU-DT] In (Select Max(X.[Thru-Dt]) From
qMembershipSelect As X Where X.MRN = Y.MRN And X.MRN Not in(Select Z.MRN
From qMembershipSelect As Z Where Z.[THRU-DT] Is Null))
ORDER BY MemNAME, [FROM-DT] DESC;
Obviously this 2nd layer of filtering wouldn't be so tedious to a smaller
dataset as it would to 1.4 million records at the start.
Are you able to do this in ADO.NET with a DataTable?... if not, how do you
go about it?
In DAO, what I would do is write the First Select Statement
qdf.SQL = "Select...."
That would become qMembershipSelect
and then refer to the rewritten query as if it were a table.
it would be nice if qMembershipSelect could be referred to with this
complexity with another dataadapter?
I don't see in ADO.NET being able to write complex SQL statements that refer
to a DataTable (equivalent to a query in Access)?
SELECT MRN, Name, Sex, DOB, SSN
FROM dbo.Membership
WHERE (MRN = @MRN or @MRN is null)
AND (Name like @Name or @Name is null)
AND (Sex = @Sex or @Sex is null)
etc.
The name of that result set is from a stored procedure called:
qMembershipSelect
for 1.4 million records, this ensures that the data will come up quickly
because all I'm doing is filtering between 1-4 parameters.
But after the first select is done, I'd like to apply additional filtering
to that result set
that weeds out other stuff like duplicate records and selects a true Current
member:
SELECT DISTINCT MRN, MemNAME AS Member, DOB, SEX, SSN, GROUP, SGR,
[FROM-DT], [THRU-DT]
FROM qMembershipSelect AS Y
GROUP BY MRN, MemNAME, DOB, SEX, SSN, GROUP, SGR, [FROM-DT], [THRU-DT]
HAVING [THRU-DT] Is Null Or [THRU-DT] In (Select Max(X.[Thru-Dt]) From
qMembershipSelect As X Where X.MRN = Y.MRN And X.MRN Not in(Select Z.MRN
From qMembershipSelect As Z Where Z.[THRU-DT] Is Null))
ORDER BY MemNAME, [FROM-DT] DESC;
Obviously this 2nd layer of filtering wouldn't be so tedious to a smaller
dataset as it would to 1.4 million records at the start.
Are you able to do this in ADO.NET with a DataTable?... if not, how do you
go about it?
In DAO, what I would do is write the First Select Statement
qdf.SQL = "Select...."
That would become qMembershipSelect
and then refer to the rewritten query as if it were a table.
it would be nice if qMembershipSelect could be referred to with this
complexity with another dataadapter?
I don't see in ADO.NET being able to write complex SQL statements that refer
to a DataTable (equivalent to a query in Access)?