Friday, February 10, 2012

Autonumber field

Hi there,
Is there a way to have an autonumber field (as in MSAccess) or some sort of
a counter field that automatically numbers records?
Thank you in advance!What version of SQL Server and why do you need it? Whats the usage of that
column? You could use identity property but please explain the usage.
MC
"PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
news:B6BD5C03-55C4-4FAB-A318-DB0763F0978D@.microsoft.com...
> Hi there,
> Is there a way to have an autonumber field (as in MSAccess) or some sort
> of
> a counter field that automatically numbers records?
> Thank you in advance!|||Well I'm busy writing a front-end in Access to populate records into an SQL
table. Firstly, the way I understand it, is to have a primary key set up on
one of the fields in order to update this table from an app like Access. But
none of the fields currently in this table can be used for a primary key, so
I've created a counter that must be the primary key. This then must obviously
be some sort of an automated numbered field...
"MC" wrote:
> What version of SQL Server and why do you need it? Whats the usage of that
> column? You could use identity property but please explain the usage.
>
> MC
>
> "PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
> news:B6BD5C03-55C4-4FAB-A318-DB0763F0978D@.microsoft.com...
> > Hi there,
> >
> > Is there a way to have an autonumber field (as in MSAccess) or some sort
> > of
> > a counter field that automatically numbers records?
> >
> > Thank you in advance!
>|||Okay. For that, you can use identity property. Usually, declare int column
and set identity. If you want to add it to exeisting table it would be
something like:
alter table Test
add ColumnName int identity(1,1) not null
MC
"PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
news:0585DF2B-3173-44FE-8941-36D9A84C6DAB@.microsoft.com...
> Well I'm busy writing a front-end in Access to populate records into an
> SQL
> table. Firstly, the way I understand it, is to have a primary key set up
> on
> one of the fields in order to update this table from an app like Access.
> But
> none of the fields currently in this table can be used for a primary key,
> so
> I've created a counter that must be the primary key. This then must
> obviously
> be some sort of an automated numbered field...
> "MC" wrote:
>> What version of SQL Server and why do you need it? Whats the usage of
>> that
>> column? You could use identity property but please explain the usage.
>>
>> MC
>>
>> "PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
>> news:B6BD5C03-55C4-4FAB-A318-DB0763F0978D@.microsoft.com...
>> > Hi there,
>> >
>> > Is there a way to have an autonumber field (as in MSAccess) or some
>> > sort
>> > of
>> > a counter field that automatically numbers records?
>> >
>> > Thank you in advance!

No comments:

Post a Comment