December 29, 2005 at 4:45 pm
Hi All,
I want to alter my table to change a column to int identity from sql, but it did not allow me to do so:
alter table ad_requests
alter column ad_request_id int [identity] (1,1)
It kept giving me error: 'Incorrect syntax near 'identity'.
Is there any trick to do that? I know I can change it from EM, but I'd like to do it in my script.
Thanks,
Minh Vu
December 29, 2005 at 4:56 pm
December 30, 2005 at 1:48 am
If you look at the way that EM does it.
CREATE TABLE dbo.tmp_yourtablename ( the new field list )
IF EXISTS(SELECT * FROM dbo.tmp_yourtablename)
EXEC('INSERT INTO dbo.dbo.tmp_yourtablename (the new field list)
SELECT the new field list FROM dbo.a_Test (HOLDLOCK TABLOCKX)')
GO
DROP TABLE dbo.yourtablename
GO
EXECUTE sp_rename N'dbo.tmp_yourtablename', N'yourtablename', 'OBJECT'
GO
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply