Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 creating dynamic keys

Author  Topic 

Ask SQLTeam Question

0 Posts

Posted - 2001-12-09 : 12:40:56
Eoin writes "i want to know whether it is possible to create dynamic primary keys in plain sql. what i am trying to do in my tables is get the max of an integer column in a table, add 1 to it, and let this value be the primary key for my table. i thought i might be able to do it like this:
INSERT INTO organisation
where telephone number is an integer column. however, apparently its not possible to place a GROUP BY function here. is there another way to do this or should this be taken care of with embedded SQL?

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2001-12-09 : 13:27:43
Is this what you were trying to achieve?

INSERT INTO organisation
SELECT MAX(TelephoneNumber)+1,... FROM organisation

What about this GROUP BY?

Go to Top of Page

- Advertisement -