insert help

  • when i do insert into...select, there is a non-identity type unique column on receiving table. i have been using newid() to generate values ( like insert into tbl_receving...select newid(), col1...from tbl_from)

    newid() values are not so efficient regards to space, so wondering what are my other options ( cannot alter receving table structure ). Help in creating a script is appreciated, thank you.

  • One option might be to declare the table up front with your identity column. Then use INSERT INTO <table> ( < all but ident column> )

    SELECT from source

    Granted, you need to know the structure up front - but I have found very few occasions to use select into

    Guarddata-

  • I would have a 2 step approach, Insert all the records into a temp table. Alter the table to include the identity column and insert the records into the table form the temp table

  • quote:


    I would have a 2 step approach, Insert all the records into a temp table. Alter the table to include the identity column and insert the records into the table form the temp table


  • that's what actually i am doing now - using a temp table 2 step process, but wondering if there is a one-step process, thx

  • do you have the bandwidth to use DTS packages? If yes you could create the sequence required before loading the data into the destination table.

    Thanks

    Lucas

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply