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
 General SQL Server Forums
 New to SQL Server Programming
 Updating stored procedure
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

taj
Starting Member

India
39 Posts

Posted - 07/04/2013 :  04:07:36  Show Profile  Reply with Quote
Hi all,

I want to create a SP,which takes the result from the select statement and update into other table.

Below is the query which i tried and its incomplete,plz help me in fixing this prob.

CREATE PROCEDURE SP_UPDATE_PATIENT_REGISTRATION_RENEW_DATE
@PID BIGINT
AS
BEGIN
UPDATE PATIENT_REGISTRATION SET RENEWAL_DATE_D =

SELECT BD.BILL_DATE_D
FROM BILL_DETAILS BD
JOIN BILL_MASTER BM ON BM.BILL_NUMBER_V = BD.BILL_NUMBER_V
JOIN PATIENT_PROFILE PP ON PP.PATIENT_ID_N = BM.PATIENT_ID_N
WHERE SERVICE_CODE_N = 293
AND BD.BILL_SETTLED_C = 'Y'
AND BM.PATIENT_ID_N=@PID
END

Thank You

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 07/04/2013 :  04:25:17  Show Profile  Reply with Quote
sounds like this

CREATE PROCEDURE SP_UPDATE_PATIENT_REGISTRATION_RENEW_DATE
@PID BIGINT
AS
BEGIN
UPDATE PR
SET RENEWAL_DATE_D =  BD.BILL_DATE_D
FROM BILL_DETAILS BD 
JOIN BILL_MASTER BM ON BM.BILL_NUMBER_V = BD.BILL_NUMBER_V
JOIN PATIENT_PROFILE PP ON PP.PATIENT_ID_N = BM.PATIENT_ID_N
JOIN PATIENT_REGISTRATION PR ON PR.PATIENT_ID_N = PP.PATIENT_ID_N
WHERE SERVICE_CODE_N = 293 
AND BD.BILL_SETTLED_C = 'Y'
AND BM.PATIENT_ID_N=@PID
END



------------------------------------------------------------------------------------------------------
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.05 seconds. Powered By: Snitz Forums 2000