Hi,
Is it possible to write a stored procedure which uses a Select statement and then Inserts the result of that select statement into a particular field as a new record, all in the same stored procedure?
Here 's my sp currently:
CREATE PROCEDURE [dbo].[usp_AddStaffEvent]
@StaffEventID int,
@StaffNo varchar (6),
@QualID varchar(10),
@Resit varchar(1),
@Submitted datetime,
@StudyOptions varchar(255),
@Aids varchar(255),
@Venue1 int,
@Venue2 int
AS
Insert into StaffEvent (StaffEventID, RLStaffNo, QualID, Resit, DateSubmitted, StudyOptions, Aids, VenueID1, VenueID2)
Values (MaxID, @StaffNo, @QualID, @Resit, @Submitted, @StudyOptions, @Aids, @Venue1, @Venue2)
GO
but I want to add
SELECT Max(StaffEvent(ID)) as MAXID FROM StaffEvent
and insert the result of this select into the first field (StaffEventID) shown above.
Thanks.
Is it possible to write a stored procedure which uses a Select statement and then Inserts the result of that select statement into a particular field as a new record, all in the same stored procedure?
Here 's my sp currently:
CREATE PROCEDURE [dbo].[usp_AddStaffEvent]
@StaffEventID int,
@StaffNo varchar (6),
@QualID varchar(10),
@Resit varchar(1),
@Submitted datetime,
@StudyOptions varchar(255),
@Aids varchar(255),
@Venue1 int,
@Venue2 int
AS
Insert into StaffEvent (StaffEventID, RLStaffNo, QualID, Resit, DateSubmitted, StudyOptions, Aids, VenueID1, VenueID2)
Values (MaxID, @StaffNo, @QualID, @Resit, @Submitted, @StudyOptions, @Aids, @Venue1, @Venue2)
GO
but I want to add
SELECT Max(StaffEvent(ID)) as MAXID FROM StaffEvent
and insert the result of this select into the first field (StaffEventID) shown above.
Thanks.
