title: SQL Server auto insert syntax
body: <p>I have code like below </p>
  
  <pre><code>CREATE PROCEDURE dbo.auto_insert_biaya_olah()
  AS
  BEGIN
      SET NOCOUNT ON
  
      DECLARE @hid VARCHAR(max);
      DECLARE @pos INT;
      DECLARE @len INT;
      DECLARE @val varchar(max);
  
      SET @hid = dbo.get_pks_kode();
      SET @pos = 0;
      SET @len = 0;
  
      WHILE CHARINDEX(',', @hid, @pos + 1) &gt; 0
      BEGIN 
          SET @len = CHARINDEX(',', @hid, @pos+1) - @pos;
          SET @val = SUBSTRING(@hid, @pos, @len);
  
          INSERT INTO PNL_TR_BIAYA_OLAH_PKS (tanggal, id_pks_pengolah, tarif_olah)
          VALUES (GETDATE(), @val, 447.6);
  
          SET @pos = CHARINDEX(',', @hid, @pos + @len) + 1;
      END
  END
  </code></pre>
  
  <p>I get an error like this in navicat:</p>
  
  <blockquote>
    <p>[Err] 42000 - [SQL Server]Incorrect syntax near ')'.</p>
  </blockquote>
  
  <p>The error is not showing which line it happens on. I'm using navicat. Thanks in advance.</p>