title: ALTER VIEW must be the only statement in batch
body: <p>I get this error message in SQL Server when I write the following ALTER VIEW statement. The ALTER VIEW line is underlined in red.</p>
  
  <pre><code>IF EXISTS(SELECT * FROM sys.views WHERE name = 'SigHierarchyView')
  ALTER VIEW [dbo].[SigHierarchyView] WITH SCHEMABINDING AS
  (
  SELECT    [Sig].[Id]
              ,[Sig].[UniqueId]
              ,[Sig].[TenantId] AS [ParentTenantId]
              ,[Sig].[Code_FR]
              ,[Sig].[Code_EN]
              ,[Sig].[DecodedText_FR]
              ,[Sig].[DecodedText_EN]
              ,[Sig].[DecodedText_ES]
              ,[Sig].[DecodedText_IT]
              ,[Sig].[DecodedText_VI]
              ,[Sig].[DecodedText_CH]
              ,[Sig].[Timestamp]
              ,[Sig].[Deleted]
              ,[Sig].[CreationDate]
              ,[Sig].[CreationUserUniqueId]
              ,[Sig].[ModificationDate]
              ,[Sig].[ModificationUserUniqueId]
              ,TenantHierarchy.[LeafTenantId] AS [TenantId]
          FROM dbo.[Sig]
          INNER JOIN dbo.TenantHierarchy ON  [Sig].TenantId = TenantHierarchy.ParentTenantId    
          WHERE  TenantHierarchy.Level = (
                      SELECT MIN(TenantHierachieIn.Level) 
                      FROM dbo.TenantHierarchy TenantHierachieIn               
                      INNER JOIN  dbo.[Sig] as SigIn  
                                  ON SigIn.TenantId = TenantHierachieIn.ParentTenantId                            
                                  AND SigIn.UniqueId = [Sig].UniqueId
                      WHERE TenantHierachieIn.[LeafTenantId] = TenantHierarchy.[LeafTenantId]
          )
  )
  </code></pre>
  
  <p>GO</p>
  
  <p>I tried putting a BEGIN and END but that didn't help. I'm using SQL Server 2012.</p>