• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

Is it possible to insert a record if there is no return from a query

Not sure if this is possible but within my query the snipped bellow returns a result to a previous one, however not every result has a previous one and what I'd like to do is insert a particular date/statement if one isn't found as I need the number of returned rows to be the same as the number of incidents.  

If <Code> Returns No result Instead insert X

INSERT INTO tbIncdientPrev
SELECT top 1 atdtInciedentDateTime, atvCustId, atvcCustFullName, IncidentLevel, atvcLocationName
FROM tbDnTestDateTime
WHERE atvcPatientId = @CustID
AND atdtTestDateTime < @PrevDate
ORDER by atdtTestDateTime DESC

Open in new window

0
Litation
Asked:
Litation
  • 3
  • 2
1 Solution
 
Ess KayEntrapenuerCommented:
yes, its possible.
in pseudocode

if methodnamehere() = (nothing / null) then doinsertstuff()
0
 
Ess KayEntrapenuerCommented:
0
 
LitationAuthor Commented:
I've requested that this question be deleted for the following reason:

needed to change original code couldnt edit
0
 
Ess KayEntrapenuerCommented:
guess that doesnt answer you question.?
0
 
LitationAuthor Commented:
Actually it did, I needed to do some messing around with it but after spending a day away from it going back to it I managed to get it to work, cheers.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now