January 7, 2002 at 4:24 pm
Does anybody know how to set up an AutoNumber field in SQL Server, like in Access?
I want a field that simply increments a number by 1 with each new record, and so creates a unique field.
Thanks!
January 7, 2002 at 4:42 pm
January 7, 2002 at 5:16 pm
Thanks! That was so easy.
January 8, 2002 at 10:50 am
January 9, 2002 at 2:23 pm
One more question on this- I created a table with 2 fields, an ID field as you showed (called "Autonumber"), and a varchar field of length 40, called "deek". I then tried to run a data import into the deek field from a text file of 3 rows, where none of the data exceeds 40 characters, and none of it is null. I keep getting the error message:
Error at destination for Row Number 3. Errors encountered so far in this task: 3.
Insert error, column 1 ('Autonumber', DBTYPE_14), status 10: Integrity violation; attempt to insert NULL data or data which violates constraints.
Unspecified error.
Can I not insert several records at once into a table where there is a counter field like "Autonumber"?
January 9, 2002 at 2:25 pm
are you trying to insert the identity field? Can you post the DDL for the talbe and the text file?
Steve Jones
January 9, 2002 at 2:38 pm
The SQL code that created the table is:
CREATE TABLE myID
(
Autonumber Int Identity(1,1),
deek varchar(40)
)
The VBScript code for the import is: Function Main()
DTSDestination("deek") = DTSSource("Col003")
Main = DTSTransformStat_OK
End Function
The import takes rows 5-7, and the data in Colum003 is "01010709000010 " in each case.
January 9, 2002 at 2:54 pm
Is Autonumber listed as one of your destination columns?
K. Brian Kelley
http://www.sqlservercentral.com/columnists/bkelley/
K. Brian Kelley
@kbriankelley
January 9, 2002 at 2:55 pm
No, only "deek"
January 9, 2002 at 3:25 pm
January 9, 2002 at 3:33 pm
No, I tried that. I can't figure it out. It seems to think I'm trying to input into the autonumber field, although I'm not.
January 9, 2002 at 4:24 pm
January 10, 2002 at 11:40 am
It's a Transform Data Task from a Text File to a SQL Server db. It works fine in my tables without identity fields.
January 10, 2002 at 12:25 pm
Interesting. Haven't had issues and I do this type of import all the time, though usually from Excel.
Are you positive there is no mapping from some field inthe text file to the identity field in the table?
Steve Jones
January 10, 2002 at 2:35 pm
To eliminate variables for error, I created a table with only those two fields, and only defined the first column in the text file as well. So there's no way any other field could be mapped to anywhere.
Viewing 15 posts - 1 through 15 (of 22 total)
You must be logged in to reply to this topic. Login to reply