title: creating / updating view using stored procedure
body: <p>I want to create or update a view using stored procedure like this:</p>
  
  <pre><code>CREATE PROC Proc_Get_Ready_Weapons
  AS
  BEGIN
  
    IF EXISTS(select * FROM sys.views where name = 'dbo.vwGetReadyWeapons')
    BEGIN
      EXEC ('CREATE VIEW dbo.vwGetReadyWeapons ... rest of view')
    END
    ELSE
    BEGIN
      EXEC ('CREATE OR REPLACE VIEW dbo.vwGetReadyWeapons ... rest of view')
    END
  
    IF @@ROWCOUNT = 0
      PRINT 'Warning: No rows were updated'  
  END
  </code></pre>
  
  <p>But getting this error:</p>
  
  <blockquote>
    <p>Msg 156, Level 15, State 1, Line 1<br>
    Incorrect syntax near the keyword 'OR'.<br>
    Warning: No rows were updated</p>
  </blockquote>