Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Stored Procedure

Stored Procedure

Scheduled Pinned Locked Moved C#
databasesql-serversysadmintutorialannouncement
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mojojojojo
    wrote on last edited by
    #1

    Hi, I have some problems with the updating of database. I will need to update 2 tables in one sql query and I am not too sure how to write a stored procedure with sql server. Need some guidance. Thanks. Regards, Jo

    C 1 Reply Last reply
    0
    • M mojojojojo

      Hi, I have some problems with the updating of database. I will need to update 2 tables in one sql query and I am not too sure how to write a stored procedure with sql server. Need some guidance. Thanks. Regards, Jo

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Where are you stuck ? What does the proc look like ?

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      M 1 Reply Last reply
      0
      • C Christian Graus

        Where are you stuck ? What does the proc look like ?

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        M Offline
        M Offline
        mojojojojo
        wrote on last edited by
        #3

        set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[UpdatePAppParty] @PID VARCHAR(10), @AID VARCHAR(10), @name VARCHAR(50), @designation VARCHAR(20), @status VARCHAR(15), @reasons VARCHAR(100) AS Begin Update [aParty eStatus] Set names = @name, designation = @designation, status = @status, reason = @reasons where aParty.APID = estatus.APID and aParty.projectID = estatus.projectID END this is the procedure that i came out with. not too sure if it is correct. Regards, Jo

        C 1 Reply Last reply
        0
        • M mojojojojo

          set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[UpdatePAppParty] @PID VARCHAR(10), @AID VARCHAR(10), @name VARCHAR(50), @designation VARCHAR(20), @status VARCHAR(15), @reasons VARCHAR(100) AS Begin Update [aParty eStatus] Set names = @name, designation = @designation, status = @status, reason = @reasons where aParty.APID = estatus.APID and aParty.projectID = estatus.projectID END this is the procedure that i came out with. not too sure if it is correct. Regards, Jo

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          That's one update statement, so just add your second statement and you're done, right ?

          Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          M 1 Reply Last reply
          0
          • C Christian Graus

            That's one update statement, so just add your second statement and you're done, right ?

            Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            M Offline
            M Offline
            mojojojojo
            wrote on last edited by
            #5

            i dont get what you mean by the second statment. The statement i have is to update 2 tables.

            V 1 Reply Last reply
            0
            • M mojojojojo

              i dont get what you mean by the second statment. The statement i have is to update 2 tables.

              V Offline
              V Offline
              Vasudevan Deepak Kumar
              wrote on last edited by
              #6

              Have the second update statement for the next table with the appropriate condition. Encapsulate the Update statements in a TRANSACTION block so that if an error occurs in one update, the data integrity is preserved.

              Vasudevan Deepak Kumar Personal Homepage
              Tech Gossips
              Regional Weblog (in Tamil) :: Voicing for the Society
              Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups