If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > ALTER Table Restart

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-31-03, 22:22
Atlasts Atlasts is offline
Registered User
 
Join Date: Oct 2003
Posts: 3
ALTER Table Restart

Trying to use sql to set the Restart values for an identity column using a value from another table. I tried:

ALTER TABLE filename ALTER COLUMN fieldname RESTART WITH ( Select MAX(masterFieldID)+ 1 from masterFileName);


It doesn't like the select, is there a way to do this in a script?

Here was my attempt:


Delete from CS_ContactX ;
Insert Into CS_ContactX (ContactID) Values ( Select MAX(ContactID)+ 1 from CS_Contact) ;
ALTER TABLE CS_ContactX ALTER COLUMN ContactID RESTART WITH ( Select MAX(ContactID)+ 1 from CS_Contact);
Select * From CS_ContactX;

Last edited by Atlasts; 10-31-03 at 22:24.
Reply With Quote
  #2 (permalink)  
Old 11-03-03, 08:20
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
The ALTER TABLE ... RESTART WITH statement can only have a numeric constant. No subselects. You will have to do this programatically. Either an Stored procedure or an application.

HTH

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On