Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL command for dropping Identity

Author  Topic 

dajonx
Starting Member

6 Posts

Posted - 2008-04-16 : 10:51:12
Hi,

Is there a way to drop a column identity using TSQL?

Also, does this code look correct?

declare @max1 int
declare @max2 int
select @max1 = max(acid) from cms_2a
alter table cms_3a add cwid int identity(@max1, 1) <------ Error
select @max2 = max(cwid) from cms_3a
alter table cms_4a add cwtid int identity(@max2, 1) <------ Error

I do not have identities on tables cms_3a and cms_4a, but I do have an identity on cms_2a.

Thank you!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-16 : 11:00:19
I think error is because you pass variables inside identity. you may need to use dynamic sql for this. why are you setting maximum value from table cms_2a as seed value?
Go to Top of Page

dajonx
Starting Member

6 Posts

Posted - 2008-04-16 : 11:04:31
Oh, you can't pass variables inside identities? I needed the maximum ID from acid on table cms_2a and start an identity on table cms_3a starting from the maximum ID in cms_2a.

Go to Top of Page

dajonx
Starting Member

6 Posts

Posted - 2008-04-16 : 16:09:17
Does anyone know a way to do this?
Go to Top of Page
   

- Advertisement -