Re: SQL question (Autoincrementing value.)

From: <joe_celko_at_my-deja.com>
Date: 2000/02/02
Message-ID: <879hnm$gje$1_at_nnrp1.deja.com>#1/1


>> How do I insert an incrementing column value in a new table? <<

You might try soemthing like this, which uses scalar subqueries to find the current highest valuec:

 INSERT INTO Table1 (keycol, ...)
  VALUES ( COALESCE(SELECT MAX(keycol) FROM Table2) +1, 0), ... );

--CELKO-- Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Feb 02 2000 - 00:00:00 CET

Original text of this message