Solved

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

Posted on 2013-05-13
5
175 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
  • 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 500 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now