title: Why am I getting an error when passing a parameter to stored procedure?
body: <p>I've created a stored procedure to split IP address into four different columns. </p>
  
  <pre><code>ALTER PROCEDURE ipaddress_split
  (
      @str as varchar(max)
  )
  AS 
  BEGIN
      SET NOCOUNT ON
  
      DECLARE @query as varchar(max)  
      SET  @query = 'SELECT   parsename('+@str+',4) as A
                          ,   parsename('+@str+',3) as B
                          ,   parsename('+@str+',2) as C
                          ,   parsename('+@str+',1) as D';
      EXEC (@query)
      SET NOCOUNT off
  END
  </code></pre>
  
  <p>However, I'm getting error when I pass a parameter.</p>
  
  <pre><code>EXEC ipaddress_split @str='191.168.1.1'
  
  Msg 102, Level 15, State 1, Line 1
  Incorrect syntax near '.1'.
  </code></pre>
  
  <p>I tried all the below mentioned combinations but with no success.</p>
  
  <pre><code>exec ipaddress_split '191.168.1.1'
  exec ipaddress_split 191.168.1.1
  exec ipaddress_split ('191.168.1.1')
  </code></pre>
  
  <p>What is the proper way to pass a parameter to stored procedure?</p>