Jump to content

Primary Key next value


WoodleySaint
 Share

Recommended Posts

I would like to add some rows to an existing table in MS SQL server 2005 which has 3 columns:

 

ProviderCodeRef (PK, int, not null)

ManagerRef (int, not null)

UnitPriceRef (int, not null)

 

The current last row is as follows:

 

ProviderCodeRef ManagerRef UnitPriceRef

164000790 164000598 164000891

 

If I run the following the record will be added.

 

Insert into ProviderCodes (ProviderCodeRef,ManagerRef,UnitPriceRef) values ('164000791','164000110','164005000');

 

so the last 2 rows are now

 

ProviderCodeRef ManagerRef UnitPriceRef

164000790 164000598 164000891

164000791 164000110 164005000

 

If I try an add a record to this table using the application GUI it throws up an error. If I add the record with the following, thereby leaving a gap in the ProviderCodeRefs.

 

Insert into ProviderCodes (ProviderCodeRef,ManagerRef,UnitPriceRef) values ('164000800','164000110','164005000');

 

I can add a record with the GUI but it is assigned the ProviderCodeRef 164000791 so the table now looks like this:

 

ProviderCodeRef ManagerRef UnitPriceRef

164000790 164000598 164000891

164000791 164000300 164000251

164000800 164000100 164005000

 

I would be able to add a further 8 records using the GUI but it would then throw an error.

 

How can I make the table use a specific ProviderCodeRef for the next record added with the GUI?

 

Thanks for any advice.

Edited by WoodleySaint
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...