title: Stored procedure to Linked server with parameters - Error
body: <p>I'm trying to create stored procedure to <strong>Linked server</strong>, which input parameter @ServerName is the name of Linked Server i use.
  In this procedure I also Declare parameter which value I want to get from Dynamic SQL Query and line.</p>
  
  <blockquote>
    <p>CREATE PROC sp_Version @ServerName varchar(30)<br>
    as<br>
    Declare @Ver varchar(10)<br>
        exec ('select @Ver from openquery(' + @ServerName + ',     ''SELECT SUBSTRING  (@@VERSION, 22, 7) = @Ver''')</p>
  </blockquote>
  
  <p>When I execute my sp i get an error saying: </p>
  
  <blockquote>
    <p>"Must declare the scalar variable "@Ver"."</p>
  </blockquote>
  
  <p>Could you please help me?</p>