Skip to main content
forgot to set the type... oops
Source Link
Kane
  • 16.8k
  • 11
  • 67
  • 95

You can use the SCOPE_IDENTITY() function to return the identity value inserted.

DECLARE @id INT
INSERT INTO [Personal] (Colums ....) VALUES (this, that, stuff)
SET @id = SCOPE_IDENTITY()

INSERT INTO [Owners] (Colums ....) VALUES (@id ....)

You can use the SCOPE_IDENTITY() function to return the identity value inserted.

DECLARE @id
INSERT INTO [Personal] (Colums ....) VALUES (this, that, stuff)
SET @id = SCOPE_IDENTITY()

INSERT INTO [Owners] (Colums ....) VALUES (@id ....)

You can use the SCOPE_IDENTITY() function to return the identity value inserted.

DECLARE @id INT
INSERT INTO [Personal] (Colums ....) VALUES (this, that, stuff)
SET @id = SCOPE_IDENTITY()

INSERT INTO [Owners] (Colums ....) VALUES (@id ....)
Source Link
Kane
  • 16.8k
  • 11
  • 67
  • 95

You can use the SCOPE_IDENTITY() function to return the identity value inserted.

DECLARE @id
INSERT INTO [Personal] (Colums ....) VALUES (this, that, stuff)
SET @id = SCOPE_IDENTITY()

INSERT INTO [Owners] (Colums ....) VALUES (@id ....)