title: How to increment a primary key in an insert statement in SQL Server 2005
body: <p>I need to write an <code>insert</code> statement into a table the columns looks like this</p>
  
  <ul>
  <li><code>demandtypeid</code> (<code>PK, FK, int, not null</code>)</li>
  <li><code>characvalueid</code> (<code>PK, FK, int, not null</code>)</li>
  <li><code>percentage</code> (<code>int null</code>)</li>
  <li><code>lastuser</code> (<code>varchar(100), null</code>)</li>
  <li><code>lastedited</code> (<code>datetime, null</code>)</li>
  </ul>
  
  <p>Here is the <code>INSERT</code> statement. Notice the there is not values at the </p>
  
  <pre><code>value( ,  , 'Bob')
  </code></pre>
  
  <p>as I think that's where the auto-increment command should go</p>
  
  <pre><code>insert into tr_demandtypecharac(demandtypeID, characvalueid, lastuser) 
  values(  , , 'Bob')
  </code></pre>
  
  <p>Please help with a simple little statement</p>
  
  <p>I just want to know how to manually insert into this table</p>
  
  <p>Here's my table structure:</p>
  
  <pre><code>CREATE TABLE [dbo].[tr_demandtypecharac](
  [demandtypeid] [int] NOT NULL,
  [characvalueid] [int] NOT NULL,
  [percentage] [int] NULL,
  [lastuser] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
  [lastedited] [datetime] NULL,
   CONSTRAINT [PK_tr_dtc_pkey] PRIMARY KEY CLUSTERED 
  (
  [demandtypeid] ASC,
  [characvalueid] ASC
  )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
   ) ON [PRIMARY]
  
  ALTER TABLE [dbo].[tr_demandtypecharac]  WITH CHECK 
  ADD CONSTRAINT [FK_tr_dtc_cvid] 
  FOREIGN KEY([characvalueid]) REFERENCES [dbo].[tr_characvalue] ([characvalueid])
  
  ALTER TABLE [dbo].[tr_demandtypecharac]  WITH CHECK 
  ADD CONSTRAINT [FK_tr_dtc_dtid] 
  FOREIGN KEY([demandtypeid]) REFERENCES [dbo].[tr_demandtype] ([demandtypeid])
  </code></pre>