Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a series of SQL statements that I need to put into one result set.
Here's a part of the SQL:
SELECT NAME,
ID,
STATUS_C,
APPT_DATE INTO #DEMO
FROM CUSTOMER
LEFT OUTER JOIN CUST_NAME ON CUST_NAME.APPT_ID = CUSTOMER.APPT_ID
WHERE SERVICE = '12345'
AND NAME LIKE ('%xxxx%')
AND STATUS_C IN (11,21);
SELECT #DEMO.ID,
NAME,
#DEMO.APPT_TIME,
EFFECTIVE_DATE,
DATEDIFF(D,#DEMO.APPT_DATE, EFFECTIVE_DATE) as days into #visits
FROM #DEMO
LEFT OUTER JOIN CUSTOMER1 ON CUSTOMER1.CUST_ID = #DEMO.ID
LEFT OUTER JOIN PROCESS ON PROCESS_ID = #DEMO.PROCESS_ID
WHERE DEPT_ID IN ('51','55','61','65','71','75','81','85'
ANSD EFFECTIVE_DATE > #DEMO.APPT_DATE and
DATEDIFF(D,#DEMO.APPT_DATE, EFFECTIVE_DATE) < 31
ORDER BY NAME ASC;
it continues - but here are the first two statements.
My question is how do I take the #temp tables - do I wrap the SQL into aliased queries and concatenate them into the one script or is there another approach I'm not thinking of?
Thanks in advance
I have this resolved. I placed this query into a stored procedure and have been getting this to display in my app.
I have this resolved. I placed this query into a stored procedure and have been getting this to display in my app.