Error in SQL Prompt 9
Ozzie
Posts: 50 Bronze 5
in SQL Prompt
This code will cause SQL Prompt to flag @totalRecords as 'Variable declared but never used.'
DECLARE @totalRecords INT; IF OBJECT_ID('tempdb.dbo.#AssessmentDetails','U' ) IS NOT NULL BEGIN DROP TABLE #AssessmentDetails END -- Must specify NULL/NOT NULL for columns creation CREATE TABLE #AssessmentDetails ( id INT IDENTITY(1,1) NOT NULL, planID INT NOT NULL, planVersion INT NOT NULL, planTry INT NOT NULL, planInstance INT NOT NULL, courseID INT NOT NULL, publishedcourseName VARCHAR(500) NOT NULL, CourseActive BIT NOT NULL, candidateId INT NOT NULL, candidateUserName VARCHAR(100) NOT NULL, candidateFirstname VARCHAR(50) NOT NULL, candidateLastName VARCHAR(50) NOT NULL, workGroupID VARCHAR(50) NOT NULL, workGroupName VARCHAR(50) NOT NULL, CandidateScore INT NOT NULL, PreOrPostFlag BIT NOT NULL, Assessmenttrydate DATETIME NOT NULL, AssessmentTryNo INT NOT NULL, RESULT VARCHAR(10) NOT NULL, Progress VARCHAR(10) NOT NULL, Score_details NVARCHAR(2000) NOT NULL ); SELECT @totalRecords=COUNT(*) FROM #AssessmentDetails;
Tagged:
Answers
I have used your script and @totalRecords INT is reported as 'Variable declared but never used.'
I think that is correct, as you are initializing @totalRecords=COUNT(*) but never actually use this variable.
If you add, for example:
at the end of your script, the issue will disappear.
Regards,
Fabiola