I would just like to send some information from a simple client to a log file, and then use the identifier created for further processing.
Is the SCOPE_IDENTITY()following used correctly :
CREATE PROCEDURE [dbo].[LogSearch]
@userName VARCHAR(50),
@dateTimeStart DATETIME
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO [WH].[dbo].[tb_Searches]
(
[UserName],
[DateTimeStart]
)
SELECT @userName,
@dateTimeStart;
SELECT SCOPE_IDENTITY() AS ProfileKey;
END;
EDIT
I edited the code for the following:
ALTER PROCEDURE [dbo].[LogSearch]
@userName VARCHAR(50),
@dateTimeStart DATETIME
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO [WH].[dbo].[tb_Searches]
(
[UserName],[DateTimeStart]
)
VALUES (@userName, @dateTimeStart);
RETURN SCOPE_IDENTITY();
END;
source
share