Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Making the execution of a query optional

Author  Topic 

simkaur
Starting Member

1 Post

Posted - 2014-01-31 : 00:29:41
Hello all,

I am using sql server management studio 2012. Please tae a minute or two to understand this problem, It's really important:(
The scenario is :
I have three table, Patient, patientAccount and Message.
Now, I am inserting values into tables Patient and Message first, and then after some time I am inserting values into PatientAccount Table.Now, the problem is in the software i am using sql with) i had this query:

select * from Patient join Message on Patient.GUID = Message.PatientGUID where Message.GUID = "..Data

and if I add PatientAccount in this query as well, like

select * from Patient join Message on Patient.GUID = Message.PatientGUID, PatientAccount where Message.GUID = "..Data

It becomes mandatory to add values to the PatientAccount table at the same moment when I am adding them to Patient and Message table, but what I really want is values to be taken up by query if there is data in the PatientAccount table, and if there is no values inserted into patientAccount table, It should pick up values from Patient and Message table only.
and I want all of it in one query.

Please please please help :(


simran

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-01-31 : 07:40:32
sorry didnt understand the problem. do you mean first check for some values in pateintaccount and if not present take from other tables?
what all will be the input from user?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -