SQL Query return value in field if no results..

dodyryda

Registered User.
Local time
Today, 04:53
Joined
Apr 6, 2009
Messages
61
Hi

I am looking to return a value in a column of my query if the query returns no results, figuring this will need to be done with a stored procedure...

does anyone know how to perform this the query i have is shown below that works fine if a job exists, all i wish to do is if no results are found return string 'No Jobs' in the equipment field of my query, ..

any pointers . will be gladly appreciated... last task finally!!!

Code:
SELECT      dbo.Calendar.[Job Date], dbo.Calendar.NextBusinessDay, dbo.JobSpec.Branch, dbo.JobSpec.[Deliver Time], dbo.JobSpec.[Job Type], 
                        dbo.JobSpec.[Company Name], dbo.JobSpec.[Site Location], dbo.JobSpec.Equipment, dbo.JobSpec.[Purchase Goods], dbo.JobSpec.Driver, 
                        dbo.Calendar.ID
FROM          dbo.Calendar INNER JOIN
                        dbo.JobSpec ON dbo.Calendar.ID = dbo.JobSpec.ID
WHERE      (dbo.Calendar.[Job Date] = [dbo].fn_AddBizDays(1)) AND (dbo.JobSpec.Branch = 'Salisbury')
 
The usual method for dealing with this problem is to run two separate queries, one query counts the number of records, if returns Zero, then display the message text you want to specify, if the results are greater than zero display the records with the other query.
 
Thanks Gizmo..

But I cannot do in 2 processes as this query is called from outside access i need to perform the action in one procedure..
 

Users who are viewing this thread

Back
Top Bottom