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. Database & SysAdmin
  3. Database
  4. How can I Inserting to a table

How can I Inserting to a table

Scheduled Pinned Locked Moved Database
helpdatabasequestionannouncement
2 Posts 2 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
    mghiassi
    wrote on last edited by
    #1

    Hi all I use stored procedure to insert to a table but the ERROR_MESSAGE function return 1 and anything else.The stored procedure like this: CREATE PROCEDURE Insert_Project (@pNumber_M int, @pRow_Agreement int, @pRow_Machine int, @pRow_Language int) AS BEGIN SET NOCOUNT ON; DECLARE @Number_O int; BEGIN TRY SELECT @Number_O=Number-sum(Number_A) FROM Machine_View WHERE Row=@pRow_Machine GROUP BY Number SET @Number_O=@Number_O-@pNumber_M INSERT INTO Project (Number_A,Number_D,Row_Agreement,Row_Machine,Row_Language) VALUES (@pNumber_M,@Number_O,@pRow_Agreement,@pRow_Machine,@pRow_Language) UPDATE Project SET Number_D=@Number_O WHERE Row_Machine=@pRow_Machine END TRY BEGIN CATCH SELECT ERROR_MESSAGE() AS ErrorMessage; END CATCH END GO Can anyone help me Thanks a lot

    C 1 Reply Last reply
    0
    • M mghiassi

      Hi all I use stored procedure to insert to a table but the ERROR_MESSAGE function return 1 and anything else.The stored procedure like this: CREATE PROCEDURE Insert_Project (@pNumber_M int, @pRow_Agreement int, @pRow_Machine int, @pRow_Language int) AS BEGIN SET NOCOUNT ON; DECLARE @Number_O int; BEGIN TRY SELECT @Number_O=Number-sum(Number_A) FROM Machine_View WHERE Row=@pRow_Machine GROUP BY Number SET @Number_O=@Number_O-@pNumber_M INSERT INTO Project (Number_A,Number_D,Row_Agreement,Row_Machine,Row_Language) VALUES (@pNumber_M,@Number_O,@pRow_Agreement,@pRow_Machine,@pRow_Language) UPDATE Project SET Number_D=@Number_O WHERE Row_Machine=@pRow_Machine END TRY BEGIN CATCH SELECT ERROR_MESSAGE() AS ErrorMessage; END CATCH END GO Can anyone help me Thanks a lot

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Comment out the try/catch block and see what error is given then.


      Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects My website

      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