ahmed17
September 20th, 2008, 09:20 AM
i have problem with stored procedure , i create procedure and it run good .
use MyTestDataBase
GO
create proc sp_with_outpt_parameters2
@id int ,
@name nvarchar(40)=Null,
@age int,
@phone nvarchar (40)=Null,
@CustomerId int output
AS
INSERT INTO Shippers VALUES (@id,@name,@age,@phone)
SELECT @CustomerId=@@Identity
but when i use this stored procedure it give me this message
-------------------------------------------------------------------
Msg 137, Level 15, State 2, Line 11
Must declare the scalar variable "@CustomerId".
-----------------------------------------------------------
DECLARE @MyIdent int
EXEC sp_with_outpt_parameters
@id=10,
@name = 'Ahmed',
@age = 35,
@phone = '15121052',
@CustomerId = @MyIdent OUTPUT
SELECT @MyIdent AS IdentityValue
SELECT id,[name], age,phone
FROM Shippers
WHERE @CustomerId = @MyIdent
use MyTestDataBase
GO
create proc sp_with_outpt_parameters2
@id int ,
@name nvarchar(40)=Null,
@age int,
@phone nvarchar (40)=Null,
@CustomerId int output
AS
INSERT INTO Shippers VALUES (@id,@name,@age,@phone)
SELECT @CustomerId=@@Identity
but when i use this stored procedure it give me this message
-------------------------------------------------------------------
Msg 137, Level 15, State 2, Line 11
Must declare the scalar variable "@CustomerId".
-----------------------------------------------------------
DECLARE @MyIdent int
EXEC sp_with_outpt_parameters
@id=10,
@name = 'Ahmed',
@age = 35,
@phone = '15121052',
@CustomerId = @MyIdent OUTPUT
SELECT @MyIdent AS IdentityValue
SELECT id,[name], age,phone
FROM Shippers
WHERE @CustomerId = @MyIdent