title: Parameterise table name in .NET/SQL?
body: <p>As the topic suggests I wish to be able to pass table names as parameters using .NET (doesn't matter which language really) and SQL Server.</p>
  
  <p>I know how to do this for values, e.g. <code>command.Parameters.AddWithValue("whatever", whatever)</code> using <code>@whatever</code> in the query to denote the parameter. The thing is I am in a situation where I wish to be able to do this with other parts of the query such as column and table names.</p>
  
  <p>This is not an ideal situation but it's one I have to use, it's not really prone to SQL injection as only someone using the code can set these table names and not the end-user. It is messy however.</p>
  
  <p>So, is what I am asking possible? </p>
  
  <p>EDIT: To make the point about SQL injection clear, the table names are only passed in by source code, depending on the situation. It is the developer who specifies this. The developer will have access to the database layer anyway, so the reason I am asking is not so much for security but just to make the code cleaner.</p>