title: is it Possible to set variable inside a View in Sql Server?
body: <p>I want to set a variable in Sql Server that is selecting date from a view the query I am using is</p>
  
  <pre><code>declare @var varchar(20)
  set @var = (SELECT Current_Period_SID FROM dbo.VW_Current_Period_SID_USNT)
  </code></pre>
  
  <p>just wondering is there a way to set variable in a view something like</p>
  
  <pre><code>CREATE VIEW mp_test AS
  declare @var varchar(20)
  
  set @var = (SELECT Current_Period_SID FROM dbo.VW_Current_Period_SID_USNT)
  
  GO
  </code></pre>
  
  <p>Doing this gives Error</p>