title: how to use string variable as table variable in scaler values function
body: <p>i am trying to make a scaler values function in sql server.</p>
  
  <p>This function will take a comma seperated string of Ids and will return comma seperated string of text values corresponding to the ids.</p>
  
  <p>i am passing all parameters (like : @tablename, @idcolumnname, @valuecolumnname, @stringofids etc). and firstly try to get single text value as </p>
  
  <p>select @valuecolumnname from @tablename where @idcolumnname= (a value from @stringofids )</p>
  
  <p>but i am not able to select the text value from table corresponding to id taken from comma seperated string of ids. it gives following error</p>
  
  <p>Must declare the table variable "@tablename". i am passing @tablename as string. what should i do.</p>