Como cambiar una columna a null?
Publicado por martin (14 intervenciones) el 01/12/2005 05:02:00
Buenas noches
Quisiera modificar las columnas de unas tablas que permitan nulos, bueno realice lo siguiente:
-- obtuve el id de la tabla
select id from sysobjects where name = 'cliente' and type = 'U'
-- con el id consulte sus columnas
select name,length,isnullable,* from syscolumns where id = 62623266
-- luego quise actualizar los campos que permitan nulos
update syscolumns
set isnullable = 1
where name <> 'codigo' and
id = 62623266
-- pero me salio este error
Server: Msg 259, Level 16, State 2, Line 1
Ad hoc updates to system catalogs are not enabled. The system administrator must reconfigure SQL Server to allow this.
Server: Msg 271, Level 16, State 1, Line 1
Column 'isnullable' cannot be modified because it is a computed column.
Se que se puede realizar de esta manera:
alter table cliente
alter column categoria_cliente varchar(8) null
go
alter table cliente
alter column contacto varchar(30) null
go
.......
pero las tablas tienen muchos campos y me va a demandar mucho tiempo quise hacerlo de manera mas rapida, pero no la encontre
Muy agradecido por las sugerencias
Saludos
Quisiera modificar las columnas de unas tablas que permitan nulos, bueno realice lo siguiente:
-- obtuve el id de la tabla
select id from sysobjects where name = 'cliente' and type = 'U'
-- con el id consulte sus columnas
select name,length,isnullable,* from syscolumns where id = 62623266
-- luego quise actualizar los campos que permitan nulos
update syscolumns
set isnullable = 1
where name <> 'codigo' and
id = 62623266
-- pero me salio este error
Server: Msg 259, Level 16, State 2, Line 1
Ad hoc updates to system catalogs are not enabled. The system administrator must reconfigure SQL Server to allow this.
Server: Msg 271, Level 16, State 1, Line 1
Column 'isnullable' cannot be modified because it is a computed column.
Se que se puede realizar de esta manera:
alter table cliente
alter column categoria_cliente varchar(8) null
go
alter table cliente
alter column contacto varchar(30) null
go
.......
pero las tablas tienen muchos campos y me va a demandar mucho tiempo quise hacerlo de manera mas rapida, pero no la encontre
Muy agradecido por las sugerencias
Saludos
Valora esta pregunta


0