"Nuno Santos" <nunos7[REMOVE]@hotmail.com> wrote in message news:e0JygyqZ...@TK2MSFTNGP15.phx.gbl...
"Gustavo Larriera [MVP]" <gux@_REMOVETHIS_mvps.org> wrote in message news:eSSSFUsZ...@TK2MSFTNGP09.phx.gbl...
"Gustavo Larriera [MVP]" <gux@_REMOVETHIS_mvps.org> wrote in message news:eSSSFUsZ...@TK2MSFTNGP09.phx.gbl...
"Nuno Santos" <nunos7[REMOVE]@hotmail.com> wrote in message news:eKx2YvsZ...@TK2MSFTNGP10.phx.gbl...
La idea es magnifica. Lo que si anticipo es que si la columna es
referenciada desde un indice, restriccion de clave foranea, funcion o vista
con atributo schemabinding, entonces el alter va a dar error.
Ejemplo:
use northwind
go
create table t1 (
c1 varchar(25),
c2 varchar(25),
c3 varchar(25) unique
)
go
create index ix_nc_t1_c1 on t1(c1)
go
create view dbo.vw_v1
with schemabinding
as
select c1, c2 from dbo.t1
go
create table t2 (
c1 varchar(25) references t1(c3)
)
go
alter table t1
alter column c1 nvarchar(25)
go
alter table t1
alter column c2 nvarchar(25)
go
alter table t1
alter column c3 nvarchar(25)
go
drop view dbo.vw_v1
go
drop table t2, t1
go
Resultado:
Server: Msg 5074, Level 16, State 3, Line 2
The object 'vw_v1' is dependent on column 'c1'.
Server: Msg 5074, Level 16, State 1, Line 2
The index 'ix_nc_t1_c1' is dependent on column 'c1'.
Server: Msg 4922, Level 16, State 1, Line 2
ALTER TABLE ALTER COLUMN c1 failed because one or more objects access this
column.
Server: Msg 5074, Level 16, State 3, Line 2
The object 'vw_v1' is dependent on column 'c2'.
Server: Msg 4922, Level 16, State 1, Line 2
ALTER TABLE ALTER COLUMN c2 failed because one or more objects access this
column.
Server: Msg 5074, Level 16, State 8, Line 2
The object 'UQ__t1__16A6A769' is dependent on column 'c3'.
Server: Msg 5074, Level 16, State 1, Line 2
The object 'FK__t2__c1__19831414' is dependent on column 'c3'.
Server: Msg 4922, Level 16, State 1, Line 2
ALTER TABLE ALTER COLUMN c3 failed because one or more objects access this
column.
AMB
--
Gustavo Larriera
Uruguay LatAm
Blog: http://sqljunkies.com/weblog/gux/
MVP profile: http://aspnet2.com/mvp.ashx?GustavoLarriera
--
Este mensaje se proporciona "COMO ESTA" sin garantias y no otorga ningun
derecho / This posting is provided "AS IS" with no warranties, and confers
no rights.
--
"Alejandro Mesa" <Alejan...@discussions.microsoft.com> wrote in message
news:51076E02-8194-4285...@microsoft.com...
son grossos muchachos
Una vez más Gracias,
Nuo Santos
--
------------------------------------------------------
Nuno Santos
nunos7[REMOVER]@hotmail.com
------------------------------------------------------
"Don Roque" <fer...@gmail.com> wrote in message
news:1117659104.2...@z14g2000cwz.googlegroups.com...
Usa la funcion OBJECTPROPERTY y excluye las que tengan la propiedad
"IsMSShipped" igual a 1.
Ejemplo:
select
table_schema,
table_name,
column_name
from
information_schema.columns
where
objectproperty(object_id(quotename(table_schema) + '.' +
quotename(table_name)), 'IsMSShipped') = 0
and data_type = 'varchar'
order by
table_schema,
table_name,
ordinal_position
AMB
--
------------------------------------------------------
Nuno Santos
nunos7[REMOVER]@hotmail.com
------------------------------------------------------
"Alejandro Mesa" <Alejan...@discussions.microsoft.com> wrote in message
news:DCA6D027-757B-448C...@microsoft.com...
"Nuno Santos" <nunos7[REMOVE]@hotmail.com> wrote in message news:e0JygyqZ...@TK2MSFTNGP15.phx.gbl...
"Ricardo Passians" <rpaSssP...@hotmail.com> wrote in message news:eU5fPwOa...@TK2MSFTNGP15.phx.gbl...