SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Making the execution of a query optional
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

simkaur
Starting Member

India
1 Posts

Posted - 01/31/2014 :  00:29:41  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 01/31/2014 :  07:40:32  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000