Hi
I am creating stored procedure for the first time. I am getting error:
Msg 207, Level 16, State 1, Procedure CHECK_IMPORT_HISTORY, Line 9 [Batch Start Line 0]
Invalid column name 'NUM_RECORDS'.
Completion time: 2022-01-28T21:42:14.6129465-08:00
I even changed the name to NUM_RECORDS_1 in the output parameter and no luck with the error.
What is wrong with my query?
Thank you
CREATE PROCEDURE CHECK_IMPORT_HISTORY (@FILENAME VARCHAR(100), @NUM_RECORDS INT OUTPUT)
AS
BEGIN
SELECT COUNT(*) AS NUM_RECORDS
FROM DBO.DataImportFileImportHistory AS T1
WHERE T1.FILENAME LIKE @FILENAME;
SELECT @NUM_RECORDS = NUM_RECORDS;
END
You need to include your variable assignment in the query
SELECT @NUM_RECORDS = COUNT(*)
FROM DBO.DataImportFileImportHistory AS T1
WHERE T1.FILENAME = @FILENAME;
January 29, 2022 at 6:19 pm
Thank you so much! It works as planned.
January 30, 2022 at 1:54 pm
This was removed by the editor as SPAM
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply