By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,107 Members | 1,323 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,107 IT Pros & Developers. It's quick & easy.

Passthrough Query which Returns 0 records...

P: 2
Hello...

I have a single passthrough query where the possiblity for it to return zero records exists. If zero records will be returned, is there a way to add some logic that will catch this and return one record with all fields filled with zeros instead of returning no records at all? If possible I would like to contain everything with-in this one query.
Dec 22 '08 #1
Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,419
I don't believe so.

It's sort of possible to create the situation with a UNION query and some selection criteria that loses the manual record if any others exist. I can't think of any way that would allow the query to run other than in a crippled way though (Checking the record count causes it to run again). Very messy. Basically, unless this is an overriding requirement, I wouldn't go there.

PS. We are talking SQL here. VBA has no such restrictions, but then you can't easily fit that logic into a query.
Dec 22 '08 #2

P: 2
Would this be a good example of a case where you would want to use a stored procedure?
Dec 23 '08 #3

NeoPa
Expert Mod 15k+
P: 31,419
This doesn't sound much like an Access question if we're going there.

Yes. In SQL Server you can define a Cursor which can be tested and returned only if not empty. Otherwise a more simple and static cursor could be returned in its stead.
Dec 23 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.