SQL Server 2008 Problem with SCOPE_IDENTITY()

Posted by jinsungy on Stack Overflow See other posts from Stack Overflow or by jinsungy
Published on 2010-04-09T15:47:10Z Indexed on 2010/04/09 15:53 UTC
Read the original article Hit count: 169

My code does not update the thread field. It is null. Anyone have any ideas?

INSERT INTO [Messages]([Sender], [Receiver], [Job_Number], [Subject], [MessageText], [DateSent])
VALUES(@Sender, @Receiver, @Job_Number, @Subject, @MessageText, @DateSent)

SET @ThreadID = SCOPE_IDENTITY()

UPDATE [Messages] 
SET Thread = @ThreadID
WHERE MessageID = @ThreadID

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about Identity