I did some research and found out that the best solution to get the id of newly inserted row is output clause.I am using the insert statement output clause for the first time and couldnt figure it out.
here is my sql code. what is wrong with this sql?
ALTER PROCEDURE [dbo].[MedBul_Insert_Message]
(@ParentID int, @MessageFrom varchar(500),@MessageTo varchar(500), @MessageSubject varchar(500),@MessageBody varchar(4000),@MessageIsRead int)
AS
BEGIN
SET LANGUAGE Turkish;
Declare @message_id table (MessageID int);
insert into Messages output INSERTED.ID INTO @message_id (ParentID ,MessageFrom ,MessageSubject ,MessageBody ,MessageIsRead ) values(@ParentID ,@MessageFrom ,@MessageSubject ,@MessageBody ,@MessageIsRead );
END