Hello All,
May anyone please help me on this.
/*
Whenever value column is empty or null then only it should appear in the output.
for eg: Desc 1 Value is blank or null or desc 2 Value is blank or null or 3 is null or blank then it should appear in output
if all value is filled then it should not appear in output.
*/
Declare @table table
(
Brand varchar (50),
Desc1 varchar (50),
Value1 varchar (50),
Desc2 varchar (50),
Value2 varchar (50),
Desc3 varchar (50),
Value3 varchar (50),
Desc4 varchar (50),
Value4 varchar (50)
)
Insert @table
select 'Cooler', 'Type', 'Air To Air', 'Number Of Pieces','' ,'Design', '', 'Height','Disc' UNION ALL
select 'AmericanAuto', 'Type', 'Universal' , 'Number Of Pieces', '4' ,'Design', 'NoLogo', 'Height', '' UNION ALL
select 'AmericanAuto', 'Type', 'Universal', 'Number Of Pieces', '4' ,'Design', '' , 'Height', '' UNION ALL
select 'FloorMat', 'Type', ' ' , 'Number Of Pieces', '6' ,'Design', 'Universal','Height', 'Black' UNION ALL
select 'LINK', 'Type', 'Black' , 'Number Of Pieces', '8' ,'Design', 'Rubber', 'Height', 'RED' UNION ALL
select 'LINK', 'Type', 'Gray' , 'Number Of Pieces', '8' ,'Design', 'Rubber', 'Height', 'RED' UNION ALL
select 'LINK', 'Type', 'Black', 'Number Of Pieces', '8', 'Design', 'Rubber', 'Height', 'RED'
SELECT * FROM @table
/*
AND OUTPUT Should be
all those records which contain atleast one blank or NULL in a attribute.
'Cooler', 'Type', 'Air To Air', 'Number Of Pieces','' ,'Design', '', 'Height','Disc'
'AmericanAuto', 'Type', 'Universal' , 'Number Of Pieces', '4' ,'Design', 'NoLogo', 'Height', ''
'AmericanAuto', 'Type', 'Universal', 'Number Of Pieces', '4' ,'Design', '' , 'Height', ''
'FloorMat', 'Type', ' ' , 'Number Of Pieces', '6' ,'Design', 'Universal','Height', 'Black'
Brand Link records will not appear in output as it doesn't contain any null or blank in any of the attribute
*/
Thanks a lot