[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2013-05-13
5
Medium Priority
?
182 Views
Last Modified: 2013-05-15
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
Comment
Question by:Litation
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:Ess Kay
ID: 39161959
yes, its possible.
in pseudocode

if methodnamehere() = (nothing / null) then doinsertstuff()
0
 
LVL 15

Accepted Solution

by:
Ess Kay earned 1500 total points
ID: 39161967
0
 

Author Comment

by:Litation
ID: 39168508
I've requested that this question be deleted for the following reason:

needed to change original code couldnt edit
0
 
LVL 15

Expert Comment

by:Ess Kay
ID: 39162423
guess that doesnt answer you question.?
0
 

Author Comment

by:Litation
ID: 39168511
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question