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_P aram1, , int> = <Default_Value_ For_Param1, , 0>,
<@Param2, sysname, @p2> <Datatype_For_P aram2, , 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_Enr ollment_AIMS
SET dbo.Payment_Enr ollment_AIMS.[PROJ END DT]= dbo.V_Payment_e nrollment_end_d t_AIMS.DTE_PROJ _END
FROM dbo.Payment_Enr ollment_AIMS JOIN dbo.V_Payment_e nrollment_end_d t_AIMS
ON dbo.Payment_Enr ollment_AIMS.En rollment_ID=dbo .V_Payment_enro llment_end_dt_A IMS.Enrollment_ ID
where dbo.Payment_Enr ollment_AIMS.JC _ID = dbo.V_Payment_e nrollment_end_d t_AIMS.JC_ID
and dbo.Payment_Enr ollment_AIMS.[PROJ START DT] =dbo.V_Payment_ enrollment_end_ dt_AIMS.[PROJ START DT]
and dbo.Payment_Enr ollment_AIMS.[Grant]=dbo.V_Payment_ enrollment_end_ dt_AIMS.[Grant]
and dbo.Payment_Enr ollment_AIMS.TE RM= dbo.V_Payment_e nrollment_end_d t_AIMS.TERM
UPDATE dbo.Payment_Pla cement_AIMS
SET dbo.Payment_Pla cement_AIMS.[EMP END DT]= dbo.V_Payment_p lacement_end_dt _AIMS.DTE_END_E MPLR
FROM dbo.Payment_Pla cement_AIMS JOIN dbo.V_Payment_p lacement_end_dt _AIMS
ON dbo.Payment_Pla cement_AIMS.JC_ ID = dbo.V_Payment_p lacement_end_dt _AIMS.JC_ID
where dbo.Payment_Pla cement_AIMS.[EMP START DT] =dbo.V_Payment_ placement_end_d t_AIMS.[EMP START DT]
and dbo.Payment_Pla cement_AIMS.[Grant]=dbo.V_Payment_ placement_end_d t_AIMS.CDE_PROJ
and dbo.Payment_Pla cement_AIMS.HOU RS= dbo.V_Payment_p lacement_end_dt _AIMS.HOURS
and dbo.Payment_Pla cement_AIMS.WAG E=dbo.V_Payment _placement_end_ dt_AIMS.WAGE
UPDATE dbo.Payment_Act ivity_AIMS
SET dbo.Payment_Act ivity_AIMS.[ACTV END DT]= dbo.V_Payment_a ctivity_end_dt_ AIMS.DTE_END_AC TV
FROM dbo.Payment_Act ivity_AIMS JOIN dbo.V_Payment_a ctivity_end_dt_ AIMS
ON dbo.Payment_Act ivity_AIMS.ACTI VITY_ID =dbo.V_Payment_ activity_end_dt _AIMS.ACTIVITY_ ID
where dbo.Payment_Act ivity_AIMS.JC_I D = dbo.V_Payment_a ctivity_end_dt_ AIMS.JC_ID
and dbo.Payment_Act ivity_AIMS.[ACTV START DT] = dbo.V_Payment_a ctivity_end_dt_ AIMS.[ACTV START DT]
and dbo.Payment_Act ivity_AIMS.[ACTIVITY CODE]= dbo.V_Payment_a ctivity_end_dt_ AIMS.[ACTIVITY CODE]
and dbo.Payment_Act ivity_AIMS.PROG RAM= dbo.V_Payment_a ctivity_end_dt_ AIMS.PROGRAM
UPDATE dbo.Payment_Act ivity_AIMS
SET dbo.Payment_Act ivity_AIMS.[ACTV END DT]= dbo.V_Payment_a ctivity_end_dt_ AIMS.DTE_END_AC TV
FROM dbo.Payment_Act ivity_AIMS JOIN dbo.V_Payment_a ctivity_end_dt_ AIMS
ON dbo.Payment_Act ivity_AIMS.ACTI VITY_ID =dbo.V_Payment_ activity_end_dt _AIMS.ACTIVITY_ ID
where dbo.Payment_Act ivity_AIMS.JC_I D = dbo.V_Payment_a ctivity_end_dt_ AIMS.JC_ID
and dbo.Payment_Act ivity_AIMS.[ACTV START DT] = dbo.V_Payment_a ctivity_end_dt_ AIMS.[ACTV START DT]
and dbo.Payment_Act ivity_AIMS.[ACTIVITY CODE]= dbo.V_Payment_a ctivity_end_dt_ AIMS.[ACTIVITY CODE]
and dbo.Payment_Act ivity_AIMS.PROG RAM= dbo.V_Payment_a ctivity_end_dt_ AIMS.PROGRAM
UPDATE dbo.Payment_Sub project_Retenti on_AIMS
SET dbo.Payment_Sub project_Retenti on_AIMS.[SUBPROJ END DT]= dbo.V_Payment_S ubproject_Reten tion_end_dt_AIM S.DTE_END_PROJ_ SUB,
dbo.Payment_Sub project_Retenti on_AIMS.PROJ_EN D_DATE= dbo.V_Payment_S ubproject_Reten tion_end_dt_AIM S.DTE_PROJ_END
FROM dbo.Payment_Sub project_Retenti on_AIMS JOIN dbo.V_Payment_S ubproject_Reten tion_end_dt_AIM S
ON dbo.Payment_Sub project_Retenti on_AIMS.Subproj ect_Retention_I D =dbo.V_Payment_ Subproject_Rete ntion_end_dt_AI MS.Subproject_R etention_ID
where dbo.Payment_Sub project_Retenti on_AIMS.JC_ID = dbo.V_Payment_S ubproject_Reten tion_end_dt_AIM S.JC_ID
and dbo.Payment_Sub project_Retenti on_AIMS.[SUBPROJ START DT] = dbo.V_Payment_S ubproject_Reten tion_end_dt_AIM S.[SUBPROJ START DT]
and dbo.Payment_Sub project_Retenti on_AIMS.[SUB PROJECT]= dbo.V_Payment_S ubproject_Reten tion_end_dt_AIM S.[SUB PROJECT]
and dbo.Payment_Sub project_Retenti on_AIMS.PROJ_ST ART_DATE= dbo.V_Payment_S ubproject_Reten tion_end_dt_AIM S.DTE_PROJ_BEGI N
UPDATE dbo.Payment_Pla cement_Retentio n_AIMS
SET dbo.Payment_Pla cement_Retentio n_AIMS.[EMP END DT]= V_Payment_Place ment_Retention_ end_dt_AIMS.DTE _END_EMPLR
FROM dbo.Payment_Pla cement_Retentio n_AIMS JOIN V_Payment_Place ment_Retention_ end_dt_AIMS
ON dbo.Payment_Pla cement_Retentio n_AIMS.Placemen t_Retention_ID =V_Payment_Plac ement_Retention _end_dt_AIMS.Pl acement_Retenti on_ID
where dbo.Payment_Pla cement_Retentio n_AIMS.JC_ID = V_Payment_Place ment_Retention_ end_dt_AIMS.JC_ ID
and dbo.Payment_Pla cement_Retentio n_AIMS.[Grant] = V_Payment_Place ment_Retention_ end_dt_AIMS.[Grant]
and dbo.Payment_Pla cement_Retentio n_AIMS.[EMP START DT]= V_Payment_Place ment_Retention_ end_dt_AIMS.[EMP START DT]
UPDATE dbo.Payment_Pla cement_Retentio n_AIMS
SET dbo.Payment_Pla cement_Retentio n_AIMS.PROJ_END _DATE = dbo.V_Payment_P lacement_Retent ion_proj_end_dt _AIMS.DTE_PROJ_ END
FROM dbo.Payment_Pla cement_Retentio n_AIMS JOIN dbo.V_Payment_P lacement_Retent ion_proj_end_dt _AIMS
ON dbo.Payment_Pla cement_Retentio n_AIMS.Placemen t_Retention_ID =dbo.V_Payment_ Placement_Reten tion_proj_end_d t_AIMS.Placemen t_Retention_ID
where dbo.Payment_Pla cement_Retentio n_AIMS.JC_ID = dbo.V_Payment_P lacement_Retent ion_proj_end_dt _AIMS.JC_ID
and dbo.Payment_Pla cement_Retentio n_AIMS.[Grant] = dbo.V_Payment_P lacement_Retent ion_proj_end_dt _AIMS.[Grant]
and dbo.Payment_Pla cement_Retentio n_AIMS.PROJ_STA RT_DATE= dbo.V_Payment_P lacement_Retent ion_proj_end_dt _AIMS.PROJ_STAR T_DATE
and dbo.Payment_Pla cement_Retentio n_AIMS.CDE_PROJ _TERM= dbo.V_Payment_P lacement_Retent ion_proj_end_dt _AIMS.CDE_PROJ_ TERM
0 2757 Sign in to post your reply or Sign up for a free account.
Similar topics |
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 stored
procedures with input parameters by which they filter rows to be updated or
inserted into other tables.
Filtration is based on certain actual values on forms (form with several
subforms).
My question is following: How to pass parameters to...
|
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 INTO Table ( ID, Cod, CodArt, Q1, DataUscita )
VALUES (pID, pCod, pCod, pQ1, pDataUscita);
|
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 dataSet
updating lark when i realised that i think i am right back at square
1!!!
Here's my scenario - i have a SQLDB and i retrieve all my data from
that into a dataset and display this to a datagrid(WebForm). I have got
this grid sorted and...
|
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 than the key value that are stored in the table.
It works well if the comboboxes are selected when the row is created.
|
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 just works for 1 row and as the
dataset doesn't have the value I should put it after and the rowstate goes
to "modified"...
Any ideas ?
| |
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 specification it should return
the number of rows affected by the stored procedure and 0 if no rows
are affected (and it does this for all other database's jdbc drivers).
I opened a PMR with IBM and received the following explanation. IBM
claims that...
|
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 framework to auto-generate a table
adapter specifying both stored procs as Get/Fill and Update. The problem is
that columns from the JOINed table seem to marked as 'read-only' so trying
to update a row results in an exception. BTW, by default a...
|
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 second table are returned by subquery. All this is done in a
stored procedure.
I also have a stored procedure that takes most of the params from the select
|
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 BundlesIssued tables updated and nothing in TicketsIssued.
Please make suggestions on how I could make this stored procedure update both tables reliably.
ALTER PROCEDURE spIssueScannedTickets
@iEventID int,
@MemberNum nvarchar(12),
...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |