尝试这样的事情:
-- create stored procedure to insert a new bug, with parameters
CREATE PROCEDURE dbo.InsertBug
@Title VARCHAR(100),
@ProjectName VARCHAR(100),
@CreatedBy VARCHAR(100)
AS BEGIN
-- variable to hold newly inserted "BugID"
DECLARE @NewBugID INT
-- do the insert into the "Bugs" table
INSERT INTO dbo.Bugs(Title, ProjectName, CreatedBy)
VALUES(@Title, @ProjectName, @CreatedBy)
-- get the new BugID that's been assigned during INSERT
SELECT @NewBugID = SCOPE_IDENTITY()
-- insert into the BugHistory table - since you didn't specify anything,
-- I assumed the bug gets assigned to whoever created it by default,
-- and I assumed "ToStatus" is a string column so I assigned "New" to it
-- ADAPT as needed !
INSERT INTO dbo.BUgHistory(BugID, AssignedTo, ToStatus)
VALUES(@NewBugID, @CreatedBy, 'New')
END