The following SQL has two identical select statements, the second of which is needed as the last thing in the stored proc (the 2nd select) is sent back to Crystal Reports (Crystal sees the last thing processed in the SP).
Is there a way of doing the following with a single select with a call within the sql to the insert statement, possibly using a user defined function (SQL S 2000 used)...
CREATE PROCEDURE dbo.uspCRYInsertTest
@ReportID INT
AS
-- Drop the the table for testing purposes
DELETE FROM tbl_cry_assessor
--Insert the assessor_id into the table
INSERT INTO tbl_cry_assessor SELECT assessor_id, getdate() FROM tbl_Crystal_HoldingData WHERE Report_ID > @ReportID
--Return the records for the report.
SELECT * FROM tbl_Crystal_HoldingData WHERE Report_ID > @ReportID
GO
Is there a way of doing the following with a single select with a call within the sql to the insert statement, possibly using a user defined function (SQL S 2000 used)...
CREATE PROCEDURE dbo.uspCRYInsertTest
@ReportID INT
AS
-- Drop the the table for testing purposes
DELETE FROM tbl_cry_assessor
--Insert the assessor_id into the table
INSERT INTO tbl_cry_assessor SELECT assessor_id, getdate() FROM tbl_Crystal_HoldingData WHERE Report_ID > @ReportID
--Return the records for the report.
SELECT * FROM tbl_Crystal_HoldingData WHERE Report_ID > @ReportID
GO