Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 ignone nulls and emptystring?

Author  Topic 

learntsql

524 Posts

Posted - 2010-09-07 : 03:46:44
Hi All,

DECLARE @tab table(Code varchar(10),CodeValue varchar(100))

insert into @tab

select 'C1','CV1'
union
select '','CV2'
union
select 'C2',''
union
select null,'CV3'
union
select null,null

select * from @tab

Now i have load this data into another table by ignoring nulls and emptystring from both the columns
i.e the output must contain
C1,CV1
TIA

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-09-07 : 04:40:04

select * from @tab
where coalesce(code,'')<>'' and coalesce(codevalue,'')<>''


or

select * from @tab
where code>'' and codevalue>''



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

learntsql

524 Posts

Posted - 2010-09-07 : 04:57:11
Thanks Madhi...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-09-07 : 05:01:47
quote:
Originally posted by learntsql

Thanks Madhi...


You are welcome

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -