Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Autofill an Integer Column

Autofill an Integer Column

Autofill an Integer Column

Hi, I'm importing a table from another data source, deleting an existing table in a SQL database and replacing the data with the new imported data. My problem is that in the destination table there needs to have a primary key, an integer column. Is there a way that when I'm exporting the new data to the destination table that I could populate an integer column with a random number or auto number?

RE: Autofill an Integer Column

Easiest way is to change that primary key to be a identity one, and change it back once load finished

Failing that.

option 2 - not feasible if volumes are high
insert into a temp table with the field defined as identity and then insert into final table

option 3 - add a transform step to your dataflow and add a incremental value to that column

option 4 - on the data source, if it is a SQL db, join your source data with a numbers table and use that as the required number


Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

RE: Autofill an Integer Column

Thanks, for the reply. Can you tell me how to change the primary key to an identity one?

RE: Autofill an Integer Column

Got it to work, thanks.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close