I've searched everywhere but could not find right reference to my query so am creating new thread. Sorry if it is a duplicate.
Basically, I'm working on a stored procedure which will retrieve data based on study parameter passed. The datasource is 'Views'. The name of the view is same for every study except that there is corresponding study name included. For example the views names are something like this for study abc 'v_abc_form' and for study def 'v_def_form'.
Below is the select statement I'm trying to use by declaring @study variable but not able to succeed. I'm not sure how to make the table name dynamic. I would appreciate if someone can walk me through this or direct me to some good references. Thanks for your help in advance.
The mess, you are already experiencing.
The risk, primarily, is a form of hacking called "SQL Injection" where people actually submit SQL Statements as parameter values which then get blended into the existing statement and executed.
If it's not practically useful, then it's practically useless.