troubleshooting Question

creating a Stored Procedure to update records in two joined tables

Avatar of adamtrask
adamtrask asked on
.NET ProgrammingC#Visual Basic.NET
7 Comments1 Solution422 ViewsLast Modified:
Hello experts,

I was introduced to Stored Procedures on Sql Server by experts on this forum.
I was shown how to create one that inserts data in two joined tables.
Since then I 've experimeting by creating a similar SP to update data in the two tables using the first SP as a model for the update version.
Unfortunately my effort hasn't succeeded so far. The data in the first table gets updated but not in the second table.

here is the update SP:

Alter PROCEDURE [dbo].[UpdateMainRemarks]
      -- Add the parameters for the stored procedure here
      @ID int,
      @dDate date,
      @tTime time,
      @mMonth nvarchar (15),
      @nName nvarchar (255),
      @sSubject nvarchar (255),
      @tType nvarchar (15),
      @sRemarks nvarchar(Max)

UPDATE Main SET dDate=@dDate, tTime=@tTime,nName=@nName,sSubject=@sSubject,tType=@tType,mMonth=@mMonth where ID=@ID
  declare @newid int, @remarks nvarchar(Max)
   set @remarks = @sRemarks

IF @sRemarks != ''
    Update tblRemarks Set mainID=@newid, Remarks=@remarks
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros