OK. I'm on to something here. However, I'm sure that the StoredProcedure
that is being executed has only one SELECT being run. And, in addition, the
"other" table that is experiencing the unexpected "Modified" is completely
different than the table which is actually being filled. Rows from the first
table wouldn't "fit" into the second table. So, I'm still puzzled.
I included the StoredProcedure that gets fired. It's not really all that
complicated and each return identical columns. And, only one ResultSet should
be returned with each execution.
IF @PNumber=-1
BEGIN
SELECT P.[Current Location], P.Bed, P.[Full Name], P.[Medical Record
Number], P.[Billing Number], COUNT(S1.[Service Record Number]) AS [Count of
Services]
FROM Patients AS P LEFT OUTER JOIN
Service AS S1 ON P.[Medical Record Number] = S1.[Medical Record
Number] AND P.[Billing Number] = S1.[Billing Number]
GROUP BY P.[Current Location], P.Bed, P.[Full Name], P.[Medical Record
Number], P.[Billing Number]
HAVING (P.[Current Location] LIKE @Unit)
ORDER BY P.[Current Location], P.[Full Name]
END
ELSE
BEGIN
SELECT P.[Current Location], P.Bed, P.[Full Name], P.[Medical Record
Number], P.[Billing Number], COUNT(S1.[Service Record Number]) AS [Count of
Services]
FROM Patients AS P LEFT OUTER JOIN
Service AS S1 ON P.[Medical Record Number] = S1.[Medical Record
Number] AND P.[Billing Number] = S1.[Billing Number]
WHERE S1.[Service Provider]=@ProviderNumber
GROUP BY P.[Current Location], P.Bed, P.[Full Name], P.[Medical Record
Number], P.[Billing Number]
HAVING (P.[Current Location] LIKE @Unit)
ORDER BY P.[Current Location], P.[Full Name]
END
END