set identity_insert mytable on local or global

  • I have an SP which turns of IDENTITY so I can add in inforamtion in to the gaps in the IDENITY column (ie. if the identity cloumn is 1,2,3,4,7,8,9 is will insert the nextt rows at 5,6 and then 10).

    when finished it will turn identity_insert back on.

    While this processes is running will all processes effectivly have the IDENTITY insert off for this table as well or is this only local to the store procedure?

    Many thanks

  • set identity_insert is at session level !

    So it will only be active with your session for your session !

    Why are you trying to fill the gaps ?

    Are you reaching the min/max integer barriers ?

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • It is session based command.In your session if you set this option ON for one table,you cannot set it ON for another table.Server level will not be affected.

  • ALZDBA (7/14/2009)


    set identity_insert is at session level !

    So it will only be active with your session for your session !

    Why are you trying to fill the gaps ?

    Are you reaching the min/max integer barriers ?

    Great so I can freely run this and any other users inserts will be added as normal.

    Yep we are filling the gaps as we are reaching the min/max integer barriers.

    Many thanks

  • - that would be a table with +- 4,000,000,000 rows .... nice

    - double check you have an index on that identity column

    - Make sure you use the propper technique to find your gaps !

    e.g. Generating Missing Dates and Numbers http://www.sqlservercentral.com/articles/Datetime+Manipulation/61822/

    Maybe its just better to get a maintenance window to rearrange your identity data!This may take some time, but will pay off in the long run, if you implemented surrogate keys.

    (and therefor will only have to modify the table itself and the first level of dependant (referencing) tables)

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Edward (7/14/2009)


    Yep we are filling the gaps as we are reaching the min/max integer barriers.

    Save yourself and others the pain... simply switch the column datatype to BIGINT. You will never run out of numbers ever again.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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