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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 creating dynamic keys
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 12/09/2001 :  12:40:56  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
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
VALUES(MAX(TelephoneNumber)+1,...etc
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?
thanks"

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 12/09/2001 :  13:27:43  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000