For you SSRS report developers out there, have you ever received the error “Must define scalar variable @<variable name>” and then drove yourself crazy trying to troubleshoot it? You probably even checked your Report Parameters a dozen more times to make sure you weren’t crazy or blind?
I have experienced this issue on several occasions while working in SQL Server Business Intelligence Development Studio. I have yet to zero in on exactly what causes this to happen, but it appears to happen during times when I am making several changes to a report in fairly quick succession, toggling between the Data, Layout, and Preview tabs.
In this example, I received the error “Must declare scalar variable @StartDate”
I looked at my input parameters (Report >> Report Parameters) and all parameters were defined. I looked at my SQL statement and all parameters were included in the query and had the correct names. Nothing seemed out of the ordinary. I then checked the Dataset settings and on the Parameters tab noticed that all of my parameters were missing. They just disappeared!
All you have to do is re-enter your parameters in this window, and your report should run just fine.


