• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 441
  • Last Modified:

AutoNumber/Counter @ Import

Hiya All,

I want to have an autonumber/counter column in a table that I import flat files into, I clear the table each time I do an import so I would like the number to start at one each time. I use DTS to import the flat file to the table.

How do I do this?

  • 2
1 Solution
dehmerlAuthor Commented:
Guess What!

I found it out myself!

Make a new row in the table, data type is int and then use the identity options!
You got it... except that it doesn't always restart the identity key at 1.

Look into DBCC CHECKIDENT (tablename, RESEED, 1)
Turn on Identity on the autonumber culumn in the table.  before you start your process, simply execute

truncate table <yourtable>

thus will reset the autonumber and delete all the records that may be left in the table.
dehmerlAuthor Commented:
ahh thanks!

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now