select a.colid ,a.name ,b.name ,a.length from syscolumns a,systypes b where a.id= object_id('表名') and a.xtype=b.xtype order by a.colid 查询表字段,返回的是一个集合(多条属性)表中任意数据,只要其中一个字段为空,即返回,也就是返回“表中任意字段为空的数据” 只提供了表名,用一条sql语句编写,求高手解答,拜谢
解决方案 »
- sql2000如何查询这样的语句
- 求助!!!replace,isnulll函数的问题!
- 求一sql语句
- 小弟不才,求一条可能是很简单的SQL语句
- Analysis Service无法启动~
- 求救!!1关于字符串中特殊字符处理的问题!!!!!
- 是不是从其它表的某个字段取值,一定要建PK?
- 怎么定期删除过期的数据?
- 请问我有一MONEY型数据12,345,678.91我想转化成12,345,679可以吗?
- 请问一个房产方面的数据库专业问题?(表如何设计)
- 请大家讨论一下同一台数据库服务器一个实例建多个数据库和建立多个实例,每个实例下一个数据的优缺点?
- mssql中如何查询最近24小时、昨天、最近7天、上周、最近30天、上月的数据记录?
---->>TravyLee生成测试数据:
if OBJECT_ID('test') is not null
drop table test
go
create table test
(
id char(4),
name varchar(51),
temp varchar(51)
)
insert test
select '0001','test01',null union all
select '0002','test02','test02' union all
select '0003','test03','test03' union all
select null,null,'test04' union all
select '0005','test05',null union all
select '0006',null,null union all
select '0007',null,null
goselect
*
from
test
where
(case when id is null then 1 else 0 end
+case when name is null then 1 else 0 end
+case when temp is null then 1 else 0 end)>0
/*
id name temp
---- --------------------------------------------------- ---------------------------------------------------
0001 test01 NULL
NULL NULL test04
0005 test05 NULL
0006 NULL NULL
0007 NULL NULL(5 行受影响)
*/