Monday, March 19, 2012

How can I made SQL modifications that I can do at EM ?

Hi all, this probably is a stupid question, but here I go.
I have read in some places that you can't set up an already existent column as IDENTITY, but in Enterprise Manager, you can do it. My question is, how EM can do this? Because I need to do this in a lot of databases, and I have to do this by SQL.

Kind Reggards
Dirceu

IDENTITY

Specifies that the new column is an identity column. When a new row is added to the table, SQL Server provides a unique, incremental value for the column. Identity columns are commonly used in conjunction with PRIMARY KEY constraints to serve as the unique row identifier for the table. The IDENTITY property can be assigned to a tinyint, smallint, int, bigint, decimal(p,0), or numeric(p,0) column. Only one identity column can be created per table. The DEFAULT keyword and bound defaults cannot be used with an identity column. Either both the seed and increment must be specified, or neither. If neither are specified, the default is (1,1).

Seed

Is the value used for the first row loaded into the table.

Increment

Is the incremental value added to the identity value of the previous row loaded.

You can add an identity column by using

alter table <table name>
add <col_name> bigint IDENTITY (1, 1)
go

|||EM adds/removes the identity property by dropping and recreating the table. You can use SQL Profiler to look at the generated SQL code and use it for your upgrade purpose. Other than dropping and recreating the table/column there is no direct DDL statement to add/drop identity property in SQL Server. SQL Server Mobile edition however permits altering a column to add identity property.|||Good,
My problem is that this table has a lot of foreign keys (other table reffer to this table and this table reffer to other tables) I have been trying to use profiler but I doesn't understand its results. I will try to see the users help.

Thanks

No comments:

Post a Comment