🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.databases.ms-sqlserver
3 messages
3 total messages Started by John A. Simpson Mon, 01 Apr 1996 00:00
Access counter type equivalent in SQL-Server 6.0
#61
Author: John A. Simpson
Date: Mon, 01 Apr 1996 00:00
13 lines
1136 bytes
I need to find out if there is some sort of equivalent to the Counter type in 
Access for SQL Server 6.0.  I already know about IDENTITY and TRIGGERs, 
however, both of these methods increment the counter field after the data is 
committed.  Our project is using the counter field as a foreign key so I need 
this field to be incremented before I commit the data.

Can anyone help me???

Thanks...

John A. Simpson
Analysts International Corp.
jsimpson@i1.net
Re: Access counter type equivalent in SQL-Server 6.0
#62
Author: Ren� Iffarth
Date: Tue, 02 Apr 1996 00:00
24 lines
1500 bytes
John A. Simpson wrote:
> 
> I need to find out if there is some sort of equivalent to the Counter type in
> Access for SQL Server 6.0.  I already know about IDENTITY and TRIGGERs,
> however, both of these methods increment the counter field after the data is
> committed.  Our project is using the counter field as a foreign key so I need
> this field to be incremented before I commit the data.
> 
> Can anyone help me???
> 
> Thanks...
> 
> John A. Simpson
> Analysts International Corp.
> jsimpson@i1.net

You should create an insert trigger, that is fetching the next value for 
the counter ( MAX(id_column)+1,... or so ) and set this value to your 
id_column in the table.

regards
Ren� Iffarth
ri@daa.de
germany
Re: Access counter type equivalent in SQL-Server 6.0
#63
Author: Gordon A. Runkle
Date: Wed, 03 Apr 1996 00:00
15 lines
1369 bytes
John A. Simpson wrote:
> 
> I need to find out if there is some sort of equivalent to the Counter type in
> Access for SQL Server 6.0.  I already know about IDENTITY and TRIGGERs,
> however, both of these methods increment the counter field after the data is
> committed.  Our project is using the counter field as a foreign key so I need
> this field to be incremented before I commit the data.

Try using the @@IDENTITY global variable.  It 
tells you what the identity value is for the row 
just inserted.  Your stored procedure, or query 
batch, can then use this value in the foreign key 
of the related table.

Gordon.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads