title: Expecting Conversation error Sql Server
body: <p>I'm trying to create a trigger in SQL Server 2008 R2 for auditing purposes. To get the proper time zone for different locations across the country I am trying to pass in a variable to an IF/ELSE IF statement to change the hours using the DATEADD() function. Here is my code:</p>
  
  <pre><code>CREATE TRIGGER epic_cover_insert
  ON epic_cover
  AFTER INSERT
  AS 
  BEGIN
  DECLARE @facilityCode INT
  
  SET @facilityCode = (SELECT RIGHT(order_num, 3) FROM epic_cover)
  -- SET NOCOUNT ON added to prevent extra result sets from
  -- interfering with SELECT statements.
  SET NOCOUNT ON;
  
  -- Insert statements for trigger here
  UPDATE epic_cover
  IF @facilityCode = 403  --for logan
      BEGIN
          SET Created_By = CASE WHEN Created_By IS NULL THEN SUSER_NAME()
                             WHEN APP_NAME() = 'Microsoft SQL Server Management Studio - Query' THEN SUSER_NAME()
                             ELSE Created_By END,
              Created_On = DATEADD(HH,-1,GETDATE()
      END
      ELSE IF @facilityCode = 203   -- for Thermont
          BEGIN
              SET Created_By = CASE WHEN Created_By IS NULL THEN SUSER_NAME()
                             WHEN APP_NAME() = 'Microsoft SQL Server Management Studio - Query' THEN SUSER_NAME()
                             ELSE Created_By END,
                  Created_On = DATEADD(HH,1,GETDATE())
          END
      ELSE IF @facilityCode = 263 --for Saint Charles
          BEGIN
              SET Created_By = CASE WHEN Created_By IS NULL THEN SUSER_NAME()
                             WHEN APP_NAME() = 'Microsoft SQL Server Management Studio - Query' THEN SUSER_NAME()
                             ELSE Created_By END,
                  Created_On = GETDATE()
          END
  END
  END
  </code></pre>
  
  <p>I'm getting all sorts of errors that all say EXPECTING CONVERSATION. I'm not sure what this means. I googled it and that just added to the confusion. </p>