title: SSRS 2008: Why does a declared query variable show in the "Define Query Parameters" window?
body: <p>I'm having trouble creating a dataset in Reporting Services 2008. Here's the query I want to use (generic-ized for public consumption):</p>
  
  <pre><code>Declare @PersonID as int
  set @PersonID = (select top 1 personID from People where name = @PersonName)
  
  select (some columns)
  from [otherTable]
  where personID = @PersonID
  </code></pre>
  
  <p>I only have one input parameter: <code>@PersonName</code>. However, Studio 2008 seems to think <code>@PersonID</code> <em>also</em> needs a value in the "Define Query Parameters" window. So when I try to only enter a value for <code>@PersonName</code>, it gives me the "This variable has already been defined". </p>
  
  <p>I'm passing <code>@PersonName</code> because I need to display a human-readable list of the people to select from a dropdown as the only user-facing parameter to the report. I realize I could do a subquery and forget the variable in the above example, but my real query is much larger/uglier, and I can't exactly add indices to the data tables, so I'd like to limit the table scans.</p>