title: Computed Columns in INSERT Statement
body: <p>Created a table:</p>
  
  <pre><code>CREATE TABLE [dbo].[tblPacks]
  (
      [ID] [int] NOT NULL,
      [BatchNumber] [varchar](30) NULL,
      [PackID] AS (CONVERT([varchar](50), 'PK' + case when len([ID]) &lt;= (3) then CONVERT([varchar](20), right((0.001) * [ID], (3)), 0) else CONVERT([varchar](20), [ID], 0) end, 0)) PERSISTED,
      [Status] [int] NULL
  )
  </code></pre>
  
  <p>Now I Had a New Requirement that Other than this sequence also can be added into this table So that I Will Remove Computed Logic and Create Table As:</p>
  
  <pre><code> CREATE TABLE [dbo].[tblPacks]
      (
          [ID] [int] NOT NULL,
          [BatchNumber] [varchar](30) NULL,
          [PackID] VARCHAR(50),
          [Status] [int] NULL
      )
  </code></pre>
  
  <p>Now I Want Two Insert Statements which <code>'PackID'</code> Should have  logic Which is Similar to this:</p>
  
  <pre><code>  AS (CONVERT([varchar](50),'PK'+case when len([ID])&lt;=(3) then
       CONVERT([varchar](20),right((0.001)*[ID],(3)),0) else
       CONVERT([varchar](20),[ID],0) end,0)) 
  </code></pre>
  
  <p>And A Normal Insert statement which has no logic How can I DO that?</p>