473,327 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

I want to update several tables using one stored procedure How can I my SQL code att.

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 below
CREATE 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>
AS
BEGIN
-- 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>

END
GO



my SQL where i now use the query as Below to update needs to be in stored procedure please help



BEGIN TRANSACTION
COMMIT (if no errors)
or
ROLLBACK (if errors)
UPDATE dbo.Payment_Enrollment_AIMS
SET dbo.Payment_Enrollment_AIMS.[PROJ END DT]= dbo.V_Payment_enrollment_end_dt_AIMS.DTE_PROJ_END
FROM dbo.Payment_Enrollment_AIMS JOIN dbo.V_Payment_enrollment_end_dt_AIMS
ON dbo.Payment_Enrollment_AIMS.Enrollment_ID=dbo.V_Pa yment_enrollment_end_dt_AIMS.Enrollment_ID
where dbo.Payment_Enrollment_AIMS.JC_ID = dbo.V_Payment_enrollment_end_dt_AIMS.JC_ID
and 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.TERM

UPDATE dbo.Payment_Placement_AIMS
SET dbo.Payment_Placement_AIMS.[EMP END DT]= dbo.V_Payment_placement_end_dt_AIMS.DTE_END_EMPLR
FROM 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_ID
where 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_PROJ
and dbo.Payment_Placement_AIMS.HOURS= dbo.V_Payment_placement_end_dt_AIMS.HOURS
and dbo.Payment_Placement_AIMS.WAGE=dbo.V_Payment_plac ement_end_dt_AIMS.WAGE

UPDATE dbo.Payment_Activity_AIMS
SET dbo.Payment_Activity_AIMS.[ACTV END DT]= dbo.V_Payment_activity_end_dt_AIMS.DTE_END_ACTV
FROM 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_ID
where dbo.Payment_Activity_AIMS.JC_ID = dbo.V_Payment_activity_end_dt_AIMS.JC_ID
and 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.PROGRAM

UPDATE dbo.Payment_Activity_AIMS
SET dbo.Payment_Activity_AIMS.[ACTV END DT]= dbo.V_Payment_activity_end_dt_AIMS.DTE_END_ACTV
FROM 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_ID
where dbo.Payment_Activity_AIMS.JC_ID = dbo.V_Payment_activity_end_dt_AIMS.JC_ID
and 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.PROGRAM

UPDATE dbo.Payment_Subproject_Retention_AIMS
SET 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_DAT E= dbo.V_Payment_Subproject_Retention_end_dt_AIMS.DTE _PROJ_END
FROM dbo.Payment_Subproject_Retention_AIMS JOIN dbo.V_Payment_Subproject_Retention_end_dt_AIMS
ON dbo.Payment_Subproject_Retention_AIMS.Subproject_R etention_ID =dbo.V_Payment_Subproject_Retention_end_dt_AIMS.Su bproject_Retention_ID
where dbo.Payment_Subproject_Retention_AIMS.JC_ID = dbo.V_Payment_Subproject_Retention_end_dt_AIMS.JC_ ID
and 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_D ATE= dbo.V_Payment_Subproject_Retention_end_dt_AIMS.DTE _PROJ_BEGIN

UPDATE dbo.Payment_Placement_Retention_AIMS
SET dbo.Payment_Placement_Retention_AIMS.[EMP END DT]= V_Payment_Placement_Retention_end_dt_AIMS.DTE_END_ EMPLR
FROM dbo.Payment_Placement_Retention_AIMS JOIN V_Payment_Placement_Retention_end_dt_AIMS
ON dbo.Payment_Placement_Retention_AIMS.Placement_Ret ention_ID =V_Payment_Placement_Retention_end_dt_AIMS.Placeme nt_Retention_ID
where dbo.Payment_Placement_Retention_AIMS.JC_ID = V_Payment_Placement_Retention_end_dt_AIMS.JC_ID
and 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_AIMS
SET dbo.Payment_Placement_Retention_AIMS.PROJ_END_DATE = dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS .DTE_PROJ_END
FROM dbo.Payment_Placement_Retention_AIMS JOIN dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS
ON dbo.Payment_Placement_Retention_AIMS.Placement_Ret ention_ID =dbo.V_Payment_Placement_Retention_proj_end_dt_AIM S.Placement_Retention_ID
where dbo.Payment_Placement_Retention_AIMS.JC_ID = dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS .JC_ID
and dbo.Payment_Placement_Retention_AIMS.[Grant] = dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS .[Grant]
and dbo.Payment_Placement_Retention_AIMS.PROJ_START_DA TE= dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS .PROJ_START_DATE
and dbo.Payment_Placement_Retention_AIMS.CDE_PROJ_TERM = dbo.V_Payment_Placement_Retention_proj_end_dt_AIMS .CDE_PROJ_TERM
Oct 17 '07 #1
0 2738

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Zlatko | last post by:
A question concerning Access Project with SQL Server: I use a stored procedure that is calling several other stored procedure which update or append values in several tables. All of them are...
9
by: joun | last post by:
Hi all, i'm using this code to insert records into an Access table from asp.net, using a stored procedure, called qry_InsertData: PARAMETERS Long, Long, Text(20), Long, DateTime; INSERT...
4
by: steroche | last post by:
I would REALLY appreciate help please please please! Im sure it is probably blindingly obvious to most of you but I am totally in the dark here!I am lost - i thought i had finally figured out this...
3
by: dbuchanan | last post by:
Hello, (Windows forms - SQL Server) I fill my datagrid with a stored procedure that includes relationships to lookup tables so that users can see the values of the combobox selections rather...
8
by: Ornette | last post by:
Hello, I have a stored procedure which generates some values in the table. When I use update() how to populate the dataset with theses values ? For the moment I use output parameter but it...
7
by: Otto Carl Marte | last post by:
Hi, When using a CallableStatement with the IBM DB2 Universal JDBC Driver the executeUpdate and getUpdateCount() methods on CallableStatement always return -1. According to the JDBC...
5
by: Bogdan | last post by:
Hi, I have a stored procedure that uses JOINs to return columns from multiple tables. I also have another stored proc that that takes a series of params and updates multiple tables. I used the...
3
by: Bogdan | last post by:
Hi, I've been struggling subqueries/joins and table adapters for some time and can't find a clear answer. I have a stored procedure that returns columns from 2 tables. Two columns from the...
3
by: stockton | last post by:
I have written the following Stored Procedure in an attempt to update two tables in the same database reliably but unfortunately it is not too successful. I ocassionaly end up with only the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.