Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autogenerate Number

Status
Not open for further replies.

grimmy

MIS
Nov 25, 1999
57
FR
I am looking for the way to autogenerate a unique number so I can key from it. I know it is Autonumber() in access but what default do I need to give the row????
 
Hi, Grimmy!
May be I don't undertand the question but
It is a little strange :
If you select the Autonumber() - you cannot set the default number for this field and it should be not not logic if you could to do that...
Autonumber is the automatic number...

 
Thanks for your reply issahar.

What I am trying to do is generate a unique number for each record in a table. I am wanting to do something similar to the GETDATE() inbuilt function which automatically adds the date to that field.
What I was saying is that to do this in access you can select autonumber as a data type which will automatically generate a unique number for that record.
What is the similar command in SQL, I am assuming that when you go into a table through enterprise manager you need to insert something into the default column as you would with the GETDATE() function.

Hope this is clearer!!!!!

 
Hi, Grimmi!

If I understood your question, you want to create in sql server via the Enterprise manager a table that will have the Field with authomatic incremented number like Autonumber in access?

In this case you need to do the next thing:
Create new table
Add new field with the next charateristics:
'ColumnName' = 'RecID'
'DataType'=int
'Lenght','Precision','Scale' - will be filled authomatically
'AllowNulls'=false
'Identify'=true
'Indentify Seed' and 'Indentify Increment' will be filled automatically

Add some new fields just for demo..
Now , if you will browse this table and add new records
your 'RecID' field will be filled out automatically...
DOn't try to put values into the RecID
You will get error...

and don't entirely don't need to give the default value - it will care for this automatically

My best regards,
Issahar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top