title: Cannot set IDENTITY_INSERT in batch
body: <p><strong>Case</strong></p>
  <p>Currently I'm working on database seeding script, executed with <code>sqlcmd</code>. For example this script sample:</p>
  <pre><code>IF (SELECT COUNT(*) FROM Genders)=0
  BEGIN
     PRINT N'Seeding table Genders...'
  
     SET IDENTITY_INSERT Genders ON
     GO
  
     INSERT INTO Genders (GenderId, Description) VALUES (0, 'Onbekend');
     INSERT INTO Genders (GenderId, Description) VALUES (1, 'Vrouw');
     INSERT INTO Genders (GenderId, Description) VALUES (2, 'Man');
     INSERT INTO Genders (GenderId, Description) VALUES (3, 'Onzijdig');
     INSERT INTO Genders (GenderId, Description) VALUES (4, 'Vrouwman');
     INSERT INTO Genders (GenderId, Description) VALUES (5, 'Manvrouw');
  
     SET IDENTITY_INSERT Genders OFF
  END
  GO
  </code></pre>
  <p><strong>Problem</strong></p>
  <p>However, if I execute it with <code>sqlcmd</code> mode in SQL Server Management Studio, it gives me this errors:</p>
  <blockquote>
  <p>Msg 102, Level 15, State 1, Line 5 Incorrect syntax near 'ON'.</p>
  <p>Msg 102, Level 15, State 1, Line 10 Incorrect syntax near 'END'.</p>
  </blockquote>
  <p>Googled some, but can't figure out what I'm doing wrong. Without the IF/BEGIN/END if does work, but I like to perform the check first.</p>
  <p><strong>Questions:</strong></p>
  <ul>
  <li>Anything I'm doing wrong?</li>
  <li>If impossible, any workaround available?</li>
  </ul>
  <p>Thanks in advance!!</p>