I have a stored procedure which has to return a bigint
as output. below if the definition.
In the body, I'm inserting a row in a table and returning the identity using @@Identity
in @LogID
output variable.
Everything works except the return part. I have tried casting, converting, selecting and setting the @LogID
to @@identity
but no luck.
The stored proc is called by enterprise library's Logging block. I'm using Write
method of Logwriter
class. This is a standard class provided by Microsoft and we have not modified it. I can't show you the code which calls the procedure as this is a DLL and don't have the source code. Anyway, I'm pretty sure it's not the C# code as I get a SQLException
so it is something in the sql. The code below is for brevity and there are lots of other columns which I have removed.They are all provided as input parameters.
I'm sure it's a stupid thing, but I'm somehow missing it.
CREATE PROCEDURE [dbo].[WriteLog]
(
@EventID int,
@Priority int,
@LogId bigint OUTPUT
)
INSERT INTO [Log] (EventID, Priority)
VALUES(@EventID,@Priority)
SET @LogID = @@identity
Go
OUTPUT
in the place where you're calling the stored procedure. But you've not shown us that bit of code.