?
Solved

auto number generation

Posted on 2003-03-10
7
Medium Priority
?
295 Views
Last Modified: 2008-02-26
hi there
 i am very new in sql database, actually i am trying to define one of my field as an  autonumber datatype and yes/no datatype, like which is available in ms access where we define our field as autonumber, n whenever a new records insert into database it will automatically incremented. and in yes/no field there is a sort of checkbox comes in the that field which returns boolean values..

Plz Hellp

0
Comment
Question by:SahdevSingh
6 Comments
 
LVL 2

Accepted Solution

by:
stiemark earned 200 total points
ID: 8109456
Use a long for autonumber with identity set.

For booleans, use bit fields (0/-1).


Mark
0
 
LVL 1

Expert Comment

by:annine
ID: 8109735
You can use "int" data type and set Identity = Yes, Identity Seed = 1, and Identity Increment = 1 for your field that you want to use as Autonumber in Access.

And you can use "bit" data type for your field that you want to use as Yes/No in Access.

Do I help you?
0
 
LVL 1

Expert Comment

by:carled
ID: 8109751
Why use a 'long' for the data type?  Most of the time an 'int' would be far more effective.  But, yes, setting it to an 'identity' type (in the table designer, down towards the bottom there is a field that allows you to do this) achieves the same effect as an 'Autonumber'.

A 'bit' data type is the equivalent of a 'yes/no' field.  Set it to 0 for 'No' and 1 for 'Yes'.  Depending on your application (ie asp, vb...) you may need to check this field for 1 or 0 rather than 'true' or 'false'.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:SahdevSingh
ID: 8110318
thankx to all of u
0
 

Expert Comment

by:CleanupPing
ID: 9276011
SahdevSingh:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 12

Expert Comment

by:monosodiumg
ID: 11092934
No comment has been added to this question in more than 257 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: stiemark http:#8109456

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

monosodiumg
EE Cleanup Volunteer
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question