title: LINQ-to-SQL .ExecuteCommand() doesn't work with parameterized object names
body: <p>I'm a little flummoxed by this one and hoping that someone can clarify what's going on.</p>
  
  <p>I'd like to programmatically disable a foreign key constraint using my LINQ-to-SQL data context.  Seemingly this should be as easy as the following:</p>
  
  <p><code>context.ExecuteCommand( "ALTER TABLE {0} NOCHECK CONSTRAINT {1}", "MyTable", "FK_MyTable_MyOtherTable" );</code></p>
  
  <p>Unfortunately, this code bombs with the SQL error "Incorrect syntax near '@p0'."</p>
  
  <p>When I fire up profiler I see that the SQL being generated is:</p>
  
  <pre><code>exec sp_executesql 
  N'ALTER TABLE @p0 NOCHECK CONSTRAINT @p1',
  N'@p0 varchar(4000),@p1 varchar(4000)',
  @p0=N'MyTable',
  @p1=N'FK_MyTable_MyOtherTable'
  </code></pre>
  
  <p>From everything I can find in SQL Books Online and in the LINQ-to-SQL documentation this should just work.  </p>
  
  <p>I've resorted to doing this instead:</p>
  
  <p><code>context.ExecuteCommand( String.Format( "ALTER TABLE {0} NOCHECK CONSTRAINT {1}", "MyTable", "FK_MyTable_MyOtherTable" ) );</code></p>
  
  <p>It works, but it sort of defeats the purpose of being able to pass in parameters to .ExecuteCommand().</p>
  
  <p>So is this some kind of quirk in LINQ-to-SQL, SQL Server or am I just really confused?</p>
  
  <p>Any insights would be much appreciated!</p>