Remove identity clause from column

  • Hi,

    I recently discovered the output clause for saving data into a history table. In a stored procedure, I do something like this:

    if not exists {tablename}_history select top 0 * from {tablename} into {tablename}_history

    delete from {tablename}

    output deleted.*

    into {tablename}_history

    The problem is that {tablename} can have an identity column. Because I use this procedure for purging several tables, I want to add some code to remove the identity clause from the history table. SET IDENTITY INSERT is not an option, because that only works is you specify all columns (msg 8101).

    Is there a statement to remove the identity clause for a column? something like 'alter table {tablename} alter column {columnname} drop identity' ???

    Wilfred
    The best things in life are the simple things

  • Update:

    I removed an identity clause with Management Studio and traced the statements. SQL is actually not executing the statement I'm looking for but it's copying data into a temp table, which is renamed :crazy:

    Wilfred
    The best things in life are the simple things

Viewing 2 posts - 1 through 1 (of 1 total)

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