你是查找空还是null select * from tb where name is null 或 select * from tb where name=''
select * from tb where tb.name is null
declare @sqlstr nvarchar(2000) select @sqlstr=name from syscolumns where id in (select id from sysobjects where name='tb') and colid=1 set @sqlstr='select * from tb where '+@sqlstr+' is null' exec(@sqlstr)
declare @field varchar(20) select @field= name from syscolumns where id=object_id(表名) and colid=2exec('select * from 表名where isnull('+@field+','''')<>'''') --不为空,为空就改=号-- declare @field varchar(20) select @field= name from syscolumns where id=object_id('LCLBILLBASIC') and colid=1 exec('select IDNO,FlowNo from LCLBILLBASIC where isnull('+@field+','''')<>''''') /* IDNO FlowNo ------------------------------ ------------------------------ 200808060059 LB200808061a*/
declare @field varchar(20) select @field= name from syscolumns where id=object_id(表名) and colid=2exec('select * from 表名where isnull('+@field+','''')<>''''') --不为空,为空就改=号-- declare @field varchar(20) select @field= name from syscolumns where id=object_id('LCLBILLBASIC') and colid=1 exec('select IDNO,FlowNo from LCLBILLBASIC where isnull('+@field+','''')<>''''') /* IDNO FlowNo ------------------------------ ------------------------------ 200808060059 LB200808061a*/
select * from tb where name is null
或
select * from tb where name=''
select @sqlstr=name from syscolumns where id in (select id from sysobjects where name='tb') and colid=1
set @sqlstr='select * from tb where '+@sqlstr+' is null'
exec(@sqlstr)
select @field= name from syscolumns where id=object_id(表名) and colid=2exec('select * from 表名where isnull('+@field+','''')<>'''') --不为空,为空就改=号--
declare @field varchar(20)
select @field= name from syscolumns where id=object_id('LCLBILLBASIC') and colid=1
exec('select IDNO,FlowNo from LCLBILLBASIC where isnull('+@field+','''')<>''''') /*
IDNO FlowNo
------------------------------ ------------------------------
200808060059 LB200808061a*/
select @field= name from syscolumns where id=object_id(表名) and colid=2exec('select * from 表名where isnull('+@field+','''')<>''''') --不为空,为空就改=号--
declare @field varchar(20)
select @field= name from syscolumns where id=object_id('LCLBILLBASIC') and colid=1
exec('select IDNO,FlowNo from LCLBILLBASIC where isnull('+@field+','''')<>''''') /*
IDNO FlowNo
------------------------------ ------------------------------
200808060059 LB200808061a*/
你第二个字段就 colid=2不就行了?