用select name from syscolumns where id in(select id from sysobjects where name='test')取出列名的结果集,用游标遍历它,取len(name),输入为0的,懒得写了
解决方案 »
- exec pro_cx '149' 不允许从数据类型 varchar 到 money 的隐性转换。请使用 CONVERT 函数来运行此查询?
- 存储过程中用IF语句出错
- 这个SQL怎么写,难住我了
- 问个用户设置问题
- 75万条数据,查询2个字段用时2分钟,求解~!附表结构。
- 急等! 一个数据库问题
- 嵌套查询加聚合函数
- 有一单机版程序用sql sql7.0作为数据库,我想把程序和sql sql7.0一起打包做安装盘,不知道用installshield把sql sql7.0打包需要那些文件
- 整理的一些常用系统表,希望对大家有帮助,呵呵
- 我在恢复一个数据库时出现一个问题,提示是这样的'操作系统不支持代码页970。RESTORE DATABASE操作异常终止’,请问是什么问题,如何解决
- 一个实战想听听大家的意见
- 安装过程提示以下错误:Command line option syntax error.Type Comemand /? for Help.
ID,
case when col1 is null then 1 else 0 end +
case when col2 is null then 1 else 0 end +
...
case when coln is null then 1 else 0 end as 空列数
from
tabname
ID,
case when col1 is null then 1 else 0 end +
case when col2 is null then 1 else 0 end +
...
case when coln is null then 1 else 0 end as 空列数
from
tabname
where ID='id' --只统计符合条件的纪录的null栏数
if object_id('tempdb..#aa')>0 drop table #aa
select iid=identity(int,1,1),D.name into #aa from sysobjects M inner join syscolumns D on M.id=D.id where D.id=Object_id('Billhead')declare @sSQL varchar(8000)
set @sSQL=''
select @sSQl=@sSQL+'+case when '+name+' is null then 1 else 0 end' from #aaset @sSQL=stuff(@sSQl,1,1,',')exec('select sheetid'+@ssql+' from 表 where id=''id''')
sql浩如烟海!
^_^
create table t1 (id int,pid int,value varchar(50),value1 varchar(50))
insert t1 (id,value)
values(1,'A')select * from t1select case when id is null then 1 else 0 end+
case when pid is null then 1 else 0 end +
case when value is null then 1 else 0 end +
case when value1 is null then 1 else 0 end as 空列数
from t1 where id=1
*********************************************************(所影响的行数为 1 行)
(所影响的行数为 1 行)
(所影响的行数为 1 行)