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.
Author |
Topic |
svgeorge
Starting Member
23 Posts |
Posted - 2007-10-17 : 14:10:42
|
I want to update several tables using one stored procedure.How can i do this I mean the syntax.etc. declaration etc.I know the basic syntax as belowCREATE PROCEDURE <Procedure_Name, sysname, ProcedureName> -- Add the parameters for the stored procedure here <@Param1, sysname, @p1> <Datatype_For_Param1, , int> = <Default_Value_For_Param1, , 0>, <@Param2, sysname, @p2> <Datatype_For_Param2, , int> = <Default_Value_For_Param2, , 0>ASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>ENDGOmy SQL where i now use the query as Below to update needs to be in stored procedure please helpBEGIN TRANSACTIONCOMMIT (if no errors)orROLLBACK (if errors)UPDATE dbo.Payment_Enrollment_AIMSSET dbo.Payment_Enrollment_AIMS.[PROJ END DT]= dbo.V_Payment_enrollment_end_dt_AIMS.DTE_PROJ_ENDFROM dbo.Payment_Enrollment_AIMS JOIN dbo.V_Payment_enrollment_end_dt_AIMS ON dbo.Payment_Enrollment_AIMS.Enrollment_ID=dbo.V_Payment_enrollment_end_dt_AIMS.Enrollment_IDwhere dbo.Payment_Enrollment_AIMS.JC_ID = dbo.V_Payment_enrollment_end_dt_AIMS.JC_IDand dbo.Payment_Enrollment_AIMS.[PROJ START DT] =dbo.V_Payment_enrollment_end_dt_AIMS.[PROJ START DT]and dbo.Payment_Enrollment_AIMS.[Grant]=dbo.V_Payment_enrollment_end_dt_AIMS.[Grant]and dbo.Payment_Enrollment_AIMS.TERM= dbo.V_Payment_enrollment_end_dt_AIMS.TERMUPDATE dbo.Payment_Placement_AIMSSET dbo.Payment_Placement_AIMS.[EMP END DT]= dbo.V_Payment_placement_end_dt_AIMS.DTE_END_EMPLRFROM dbo.Payment_Placement_AIMS JOIN dbo.V_Payment_placement_end_dt_AIMS ON dbo.Payment_Placement_AIMS.JC_ID = dbo.V_Payment_placement_end_dt_AIMS.JC_IDwhere dbo.Payment_Placement_AIMS.[EMP START DT] =dbo.V_Payment_placement_end_dt_AIMS.[EMP START DT]and dbo.Payment_Placement_AIMS.[Grant]=dbo.V_Payment_placement_end_dt_AIMS.CDE_PROJand dbo.Payment_Placement_AIMS.HOURS= dbo.V_Payment_placement_end_dt_AIMS.HOURSand dbo.Payment_Placement_AIMS.WAGE=dbo.V_Payment_placement_end_dt_AIMS.WAGEUPDATE dbo.Payment_Activity_AIMSSET dbo.Payment_Activity_AIMS.[ACTV END DT]= dbo.V_Payment_activity_end_dt_AIMS.DTE_END_ACTVFROM dbo.Payment_Activity_AIMS JOIN dbo.V_Payment_activity_end_dt_AIMS ON dbo.Payment_Activity_AIMS.ACTIVITY_ID =dbo.V_Payment_activity_end_dt_AIMS.ACTIVITY_IDwhere dbo.Payment_Activity_AIMS.JC_ID = dbo.V_Payment_activity_end_dt_AIMS.JC_IDand dbo.Payment_Activity_AIMS.[ACTV START DT] = dbo.V_Payment_activity_end_dt_AIMS.[ACTV START DT]and dbo.Payment_Activity_AIMS.[ACTIVITY CODE]= dbo.V_Payment_activity_end_dt_AIMS.[ACTIVITY CODE]and dbo.Payment_Activity_AIMS.PROGRAM= dbo.V_Payment_activity_end_dt_AIMS.PROGRAMUPDATE dbo.Payment_Activity_AIMSSET dbo.Payment_Activity_AIMS.[ACTV END DT]= dbo.V_Payment_activity_end_dt_AIMS.DTE_END_ACTVFROM dbo.Payment_Activity_AIMS JOIN dbo.V_Payment_activity_end_dt_AIMS ON dbo.Payment_Activity_AIMS.ACTIVITY_ID =dbo.V_Payment_activity_end_dt_AIMS.ACTIVITY_IDwhere dbo.Payment_Activity_AIMS.JC_ID = dbo.V_Payment_activity_end_dt_AIMS.JC_IDand dbo.Payment_Activity_AIMS.[ACTV START DT] = dbo.V_Payment_activity_end_dt_AIMS.[ACTV START DT]and dbo.Payment_Activity_AIMS.[ACTIVITY CODE]= dbo.V_Payment_activity_end_dt_AIMS.[ACTIVITY CODE]and dbo.Payment_Activity_AIMS.PROGRAM= dbo.V_Payment_activity_end_dt_AIMS.PROGRAMUPDATE dbo.Payment_Subproject_Retention_AIMSSET dbo.Payment_Subproject_Retention_AIMS.[SUBPROJ END DT]= dbo.V_Payment_Subproject_Retention_end_dt_AIMS.DTE_END_PROJ_SUB,dbo.Payment_Subproject_Retention_AIMS.PROJ_END_DATE= dbo.V_Payment_Subproject_Retention_end_dt_AIMS.DTE_PROJ_ENDFROM dbo.Payment_Subproject_Retention_AIMS JOIN dbo.V_Payment_Subproject_Retention_end_dt_AIMS ON dbo.Payment_Subproject_Retention_AIMS.Subproject_Retention_ID =dbo.V_Payment_Subproject_Retention_end_dt_AIMS.Subproject_Retention_IDwhere dbo.Payment_Subproject_Retention_AIMS.JC_ID = dbo.V_Payment_Subproject_Retention_end_dt_AIMS.JC_IDand dbo.Payment_Subproject_Retention_AIMS.[SUBPROJ START DT] = dbo.V_Payment_Subproject_Retention_end_dt_AIMS.[SUBPROJ START DT]and dbo.Payment_Subproject_Retention_AIMS.[SUB PROJECT]= dbo.V_Payment_Subproject_Retention_end_dt_AIMS.[SUB PROJECT]and dbo.Payment_Subproject_Retention_AIMS.PROJ_START_DATE= dbo.V_Payment_Subproject_Retention_end_dt_AIMS.DTE_PROJ_BEGINUPDATE dbo.Payment_Placement_Retention_AIMSSET dbo.Payment_Placement_Retention_AIMS.[EMP END DT]= V_Payment_Placement_Retention_end_dt_AIMS.DTE_END_EMPLRFROM dbo.Payment_Placement_Retention_AIMS JOIN V_Payment_Placement_Retention_end_dt_AIMS ON dbo.Payment_Placement_Retention_AIMS.Placement_Retention_ID =V_Payment_Placement_Retention_end_dt_AIMS.Placement_Retention_IDwhere dbo.Payment_Placement_Retention_AIMS.JC_ID = V_Payment_Placement_Retention_end_dt_AIMS.JC_IDand dbo.Payment_Placement_Retention_AIMS.[Grant] = V_Payment_Placement_Retention_end_dt_AIMS.[Grant]and dbo.Payment_Placement_Retention_AIMS.[EMP START DT]= V_Payment_Placement_Retention_end_dt_AIMS.[EMP START DT]UPDATE dbo.Payment_Placement_Retention_AIMSSET dbo.Payment_Placement_Retention_AIMS.PROJ_END_DATE = dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS.DTE_PROJ_ENDFROM dbo.Payment_Placement_Retention_AIMS JOIN dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS ON dbo.Payment_Placement_Retention_AIMS.Placement_Retention_ID =dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS.Placement_Retention_IDwhere dbo.Payment_Placement_Retention_AIMS.JC_ID = dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS.JC_IDand dbo.Payment_Placement_Retention_AIMS.[Grant] = dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS.[Grant]and dbo.Payment_Placement_Retention_AIMS.PROJ_START_DATE= dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS.PROJ_START_DATEand dbo.Payment_Placement_Retention_AIMS.CDE_PROJ_TERM= dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS.CDE_PROJ_TERM |
|
|
|
|
|
|