didnt quite understand your question but check out BOL for SCOPE_IDENTITY().
CREATE PROCEDURE AddBox
(
@.BoxNumber nvarchar(40),
@.LocId int,
@.BoxNotes Text,
--This gets added to a different table that I'll call References, but can't go until I can get the uniqueID of what is inserted.
@.ReferenceID int
)AS
INSERT INTO box
(
box_num,
loc_id,
box_notes,
status_id
)VALUES
(
@.BoxNumber,
@.Locid,
@.BoxNotes,
2
)
hth|||Just the point in the right direction I needed, Thanks.
Once I inserted a new box file into the Box table I then was able to get the Unique ID number and then insert that into a reference table. The end code (after the first insert) for my previous post ends up looking as such:
Set @.Identity = SCOPE_IDENTITY()
Set @.Reference = @.ReferenceNumber
Insert into reference
(
reference_name,
box_id
)
VALUES
(
@.Reference,
@.Identity
)
GO
No comments:
Post a Comment