Home All Groups Group Topic Archive Search About

copy a db, identity problem

Author
22 Jul 2005 2:41 PM
Carlo
hi
i need to copy a db to another db every single table to another similar to
the first one but with some difference. When i try to do that i need to
remove some constraint and all the identity on the new db. i'd like do that
with a script, i tried:


CREATE TABLE (
    id int IDENTITY (1,1) NOT NULL
)

ALTER TABLE  prova ALTER COLUMN id int null
GO

it doesnt work.

how can i remove identity from a column of my table??
tx
carlo

Author
22 Jul 2005 2:45 PM
Anith Sen
>> how can i remove identity from a column of my table??

You cannot do this directly. The alternative is to create another table,
copy the data & rename it. The EM interface can get this done with a few
mouse clicks and it may perform reasonably for small-medium sized tables.

--
Anith
Author
22 Jul 2005 2:47 PM
David Portas
You can't directly remove the IDENTITY property. You would have to
create a new column or new version of the table.

However, you can use the SET IDENTITY_INSERT option to allow you to
populate the column without removing the IDENTITY property. See Books
Online for details.

--
David Portas
SQL Server MVP
--
Author
22 Jul 2005 2:51 PM
ML
You don't need to. And, actually, you shouldn't. Look up SET IDENTITY_INSERT
in Books Online. And then use it.

It helps you achieve exactly what you need (judging from your post).


ML

AddThis Social Bookmark Button