bender007
asked on
Changing Identity Specification in all tables
How would one change identity specification in all tables in a DB ? I have a backup DB thats an exact replication of the production, but in order to copy data , Identity specification needs to be disabled.
How do i do that without having to open each table individually in design mode ?
How do i do that without having to open each table individually in design mode ?
ASKER
yes I am aware of setting the identity_insert when doing an insert. But i was looking for a query that would permanently disable Identity speculation on all tables in a DB.
ASKER
should read "identity specification"
run this, copy the results and run it on another Query window
select 'Set identity_insert '+TABLE_NAME+' on '
from information_schema.tables
WHERE IDENT_CURRENT(TABLE_NAME) IS NOT NULL
select 'Set identity_insert '+TABLE_NAME+' on '
from information_schema.tables
WHERE IDENT_CURRENT(TABLE_NAME) IS NOT NULL
ASKER
Thanks,
The query ran fine, but Identity specification and Identity Increment still was not disabled
The query ran fine, but Identity specification and Identity Increment still was not disabled
Did u copy the result from the result pane and run those results on a new query window
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>you can only enable identity_insert for one table at a time.
Yup, I agree
Yup, I agree
ASKER
I just opened each table in design mode and disabled the identity increment option.
>>I just opened each table in design mode and disabled the identity increment option.<<
Than you followed BrandonGalderisi (you just don't know it) EM will basically do the following behind the scenes:
"create a new table with the columns in the correct order, copy the data over, drop the old table and rename the new to take the same name."
Than you followed BrandonGalderisi (you just don't know it) EM will basically do the following behind the scenes:
"create a new table with the columns in the correct order, copy the data over, drop the old table and rename the new to take the same name."
ASKER
Oh ok , Thanks for that info. I appreciate it.
Open in new window