Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
bwill1980
Starting Member
1 Post |
Posted - 2009-02-12 : 05:03:12
|
Dear All,I have a small SQL database that users imput data via Access.There are two main fields in the table tbProjectsProjectID (int, autonumber, primary key, hidden)ProjectNumber (numeric, no user entry)The table also contains other fieldsAfter the user has completed data entry for a record and clicked ok, I need SQL to assign an project number to the ProjectNumber field and display it in a windiow.The project numbers are incremental e.g 4000 4001 4002Can anyone help? |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2009-02-12 : 05:24:20
|
use an identity field if they are incremental, usage iscreate table <tablename>ProjectNumber numeric(15,0) identity(<startseed>,<increment>) NOT NULL,<...> |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-12 : 05:46:01
|
if ur table is already created with out identity columnsdo asright click on tablename and click on design modein column properties identityspecification --> yes --> give value as idetnity seed as 4000 and identity increment as 1 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-02-12 : 07:27:58
|
eventhough u change in design mode, if ur table has already data it will not allocate autonumber starting from 4000 to already existing records. It will allocate numbers by autoincrementing for new records which are inserted after setting identity property |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2009-02-12 : 07:30:35
|
see thishttp://www.mssqltips.com/tip.asp?tip=1397 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-12 : 09:37:16
|
you could however alter table to add a new identity column which will get autonumbered automatically starting from your prescribed seed value. |
|
|
|
|
|