Groups | Blog | Home
all groups > sql server programming > august 2003 >

sql server programming : Alter table



Manoj
8/22/2003 11:39:51 PM
Hi...
i want to alter table using query analyser, and i want to
change the data type from numeric to numeric identity.
after this command -
"alter table new_khasra_details alter column khasra_id
numeric IDENTITY "
it gives the following error---
Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'IDENTITY'.


Please help

Thanks
oj
8/23/2003 1:17:42 AM
you cannot use 'alter' to add/drop identity property. aside that, you have
to take note at having numeric identity column - this column must have a
scale of 0 hence it will be truncated...

here is a quick demo for ya.

create table t(i numeric(18,2), j varchar)
insert t select 1.0,'a' union all select 1.2,'b'
go
select top 0 i=identity(numeric,1,1),j
into t2
from t
GO
set identity_insert t2 on

insert t2(i,j)
select i,j
from t

set identity_insert t2 off
go
select * from t2
go
drop table t
go
exec sp_rename 't2','t'
go
drop table t
go


--
-oj
Rac v2.2 & QALite!
http://www.rac4sql.net


[quoted text, click to view]

AddThis Social Bookmark Button