Forums
This topic is locked
how do you do an Auto ID insert in SQL?
Posted 01 Jun 2002 06:45:48
1
has voted
01 Jun 2002 06:45:48 chris espino posted:
my backend is an SQL Server 2000VBSCRIPT
here's my table
tblProject
- ID +Primary Key
- Project
my problem is that it won't autoinsert an ID, and the only solution for me is to manually put a number.
the following is setup:
Coumn: ID
Data Type: Int
Length: 4
Allow Null: check (had to insert # manually)
Column: tblProject
Data Type: nvarchar
Length: 50
Allow Null: none
from the Design Table should I have something in Default? like Auto?
I think this is the same problem that I have with my other table, where it has an ID and could not enter any information.
thanks in advance!
Replies
Replied 03 Jun 2002 03:16:33
03 Jun 2002 03:16:33 b w replied:
under the ID and Primary key table column you should be able to see the Identity is set to 'no'. Set it to 'yes'. When you do the insert in the front end to not insert anything for the ID+Primary key (because it is inserted automatically) part but just for the project. Also make sure the permissions are set to allow for Insert for the table.
ps I don't think you can have nulls in the ID+primary key portion so it must be unchecked.
Edited by - biffysix on 03 Jun 2002 03:17:34
ps I don't think you can have nulls in the ID+primary key portion so it must be unchecked.
Edited by - biffysix on 03 Jun 2002 03:17:34
Replied 03 Jun 2002 22:59:12
03 Jun 2002 22:59:12 chris espino replied:
thanks!
I thought by default ID will autogenerate, I guess it was only with Access. I did put it in 'YES' and the numbers were generated!
I'm looking around for good books, but couldn't find anything that interested me so I just downloaded the SQL Books from Microsoft.
I thought by default ID will autogenerate, I guess it was only with Access. I did put it in 'YES' and the numbers were generated!
I'm looking around for good books, but couldn't find anything that interested me so I just downloaded the SQL Books from Microsoft.
Replied 04 Jun 2002 17:30:53
04 Jun 2002 17:30:53 Yeah Right replied:
This is Server 2000 equivilant of Access autonumber:
CREATE TABLE [dbo].[YourTable]
(
[ID] [int] IDENTITY (1, 1) NOT NULL ,
)
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
my backend is an SQL Server 2000
VBSCRIPT
here's my table
tblProject
- ID +Primary Key
- Project
my problem is that it won't autoinsert an ID, and the only solution for me is to manually put a number.
the following is setup:
Coumn: ID
Data Type: Int
Length: 4
Allow Null: check (had to insert # manually)
Column: tblProject
Data Type: nvarchar
Length: 50
Allow Null: none
from the Design Table should I have something in Default? like Auto?
I think this is the same problem that I have with my other table, where it has an ID and could not enter any information.
thanks in advance!
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
CREATE TABLE [dbo].[YourTable]
(
[ID] [int] IDENTITY (1, 1) NOT NULL ,
)
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
my backend is an SQL Server 2000
VBSCRIPT
here's my table
tblProject
- ID +Primary Key
- Project
my problem is that it won't autoinsert an ID, and the only solution for me is to manually put a number.
the following is setup:
Coumn: ID
Data Type: Int
Length: 4
Allow Null: check (had to insert # manually)
Column: tblProject
Data Type: nvarchar
Length: 50
Allow Null: none
from the Design Table should I have something in Default? like Auto?
I think this is the same problem that I have with my other table, where it has an ID and could not enter any information.
thanks in advance!
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>