How can I Inserting to a table
-
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
-
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
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