<p>I writing a report in Visual Studio that takes a user input parameter and runs against an ODBC datasource. I would like to write the query manually and have reporting services replace part of the where clause with the parameter value before sending it to the database. What seems to be happening is that the <code>@parmName</code> I am assuming will be replaced is actually being sent as part of the SQL statement. Am I missing a configuration setting somewhere or is this simply not possible?</p>

<p>I am not using the filter option in the tool because this appears to bring back the full dataset from the database and do the filtering on the SQL Server.</p>

[{'answer_id': 9325, 'author': 'Jorriss', 'author_id': 621, 'author_profile': 'https://Stackoverflow.com/users/621', 'pm_score': 4, 'selected': True, 'text': '<p>It sounds like you\'ll need to treat the SQL Statement as an expression. For example:</p>\n\n<pre><code>="Select col1, col2 from table 1 Where col3 = " &amp; Parameters!Param1.Value \n</code></pre>\n\n<p>If the where clause is a string you would need to do the following:</p>\n\n<pre><code>="Select col1, col2 from table 1 Where col3 = \'" &amp; Parameters!Param1.Value &amp; "\'"\n</code></pre>\n\n<p>Important: Do not use line breaks in your SQL expression. If you do you will get an error.</p>\n\n<p>Holla back if you need any more assistance.</p>\n'}, {'answer_id': 19600, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 1, 'selected': False, 'text': '<p>Doesn\'t ODBC use the old "?" syntax for parameters? Try this:</p>\n\n<pre><code>select col1, col2 from table1 where col3 = ?\n</code></pre>\n\n<p>The order of your parameters becomes important then, but it\'s less vulnerable to SQL injection than simply appending the parameter value.</p>\n'}, {'answer_id': 28572, 'author': 'stjohnroe', 'author_id': 2985, 'author_profile': 'https://Stackoverflow.com/users/2985', 'pm_score': 0, 'selected': False, 'text': '<p>I am a bit confused about this question, if you are looking for simple parameter usage then the notation is :<code>*paramName*</code> , however if you want to structurally change the <code>WHERE</code> clause (as you might in sql+ using ?) then you should really be using custom code within the report to define a function that returns the required sql for the query.</p>\n\n<p>Unfortunately, when using custom code, parameters cannot be referenced directly in the generated query but have to have there values concatenated into the resultant String, thus introducing the potential for <code>SQL</code> injection.</p>\n'}, {'answer_id': 10551669, 'author': 'H.G.', 'author_id': 1238246, 'author_profile': 'https://Stackoverflow.com/users/1238246', 'pm_score': 1, 'selected': False, 'text': '<p>Encountered same problem trying to query an access database via ODBC. </p>\n\n<p>My original query: <code>SELECT A.1 FROM A WHERE A.1 = @parameter</code> resulted in error. Altered to: <code>SELECT A.1 FROM A WHERE A.1 = ?</code>.</p>\n\n<p>You then have to map the query parameter with your report parameter.</p>\n'}]
['https://Stackoverflow.com/questions/9275', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1104/']