表
select CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name= 'Alliance'
select CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name= 'Alliance' and CHARACTER_MAXIMUM_LENGTH is not null;
select CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name= 'Alliance' and CHARACTER_MAXIMUM_LENGTH is null;
当遇到Case(字段)..when..then..when.. then..else...end
select case ISNULL(Cast(CHARACTER_MAXIMUM_LENGTH as varchar(10)),'') when '' then '' else '('+Cast(CHARACTER_MAXIMUM_LENGTH as varchar(10))+')' end as DATA from information_schema.columns where table_name= 'Alliance'
一定要用ISNULL转化过来,不能用when NULL
或者使用
case when field is null then...else..end
select case when CHARACTER_MAXIMUM_LENGTH is null then '' else '('+Cast(CHARACTER_MAXIMUM_LENGTH as varchar(10))+')' end as DATA from information_schema.columns where table_name= 'Alliance'