title: Is it possible to execute a sql statement containing variable?
body: <p>Is it possible to execute a sql statement containing variable?   </p>
  
  <pre><code>    DECLARE @SCHEMA varchar(40)
  
      set @SCHEMA='X_SLF'
  
     select * from @SCHEMA..Acc_tblCompany  --// anyway to use this type of statement?
  
     --below statement works 
      select * from X_SLF..Acc_tblCompany
  </code></pre>
  
  <p>--I don't want to do this following solution:</p>
  
  <pre><code>    DECLARE @Sql nvarchar(80)
      set @Sql=' select * from '+@SCHEMA+'..Acc_tblCompany'
      Execute sp_executesql @Sql
  </code></pre>