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.
| Author |
Topic |
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-10 : 07:00:55
|
| select COALESCE(NULLIF(isid,''),'No Data') as Spon from members where isid='U100000002' and aid not like 'R%'group by isidI need no Data But it gives Blank. Please help meVed Prakash Jha |
|
|
aprichard
Yak Posting Veteran
62 Posts |
Posted - 2008-09-10 : 07:11:08
|
| Hi,select COALESCE(isid,'No Data') as Spon from members where isid='U100000002' and aid not like 'R%'group by isidif value of isid is null, that will return 'No Data'ByRichard |
 |
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-10 : 07:22:27
|
| I m talking about When fetched Data is nullThen query will shows me 'No Data'select COALESCE(isid,'No Data') as Spon from memberswhere isid='U100000002' and aid not like 'R%'group by isidstill not workingVed Prakash Jha |
 |
|
|
sunil
Constraint Violating Yak Guru
282 Posts |
Posted - 2008-09-10 : 07:26:13
|
| Declare @tbl1 Table( ID int,nam varchar(20))Insert into @tbl1Select 1,'sunil' union allselect 2,NULLSelect COALESCE(nam,'No Data') as Col from @tbl1Whats the data type of isid? COALESCE will convert result to higher precedence datatype. Check COALESCE in BOL. |
 |
|
|
aprichard
Yak Posting Veteran
62 Posts |
Posted - 2008-09-10 : 07:26:28
|
| can u explian briefly |
 |
|
|
vedjha
Posting Yak Master
228 Posts |
Posted - 2008-09-10 : 07:30:35
|
| isid varchar(10)plz explain in briefVed Prakash Jha |
 |
|
|
sunil
Constraint Violating Yak Guru
282 Posts |
Posted - 2008-09-10 : 07:37:15
|
quote: Originally posted by vedjha isid varchar(10)plz explain in briefVed Prakash Jha
Not sure why you are not getting 'No Data' if isId is NULL. I tried below code and it shows 'No Data'Declare @tbl2 Table( ID varchar(10),nam varchar(20))Insert into @tbl2Select 'U123456789','sunil' union allselect NULL,'another' union allselect NULL ,'kumar' Select COALESCE(ID,'No Data') as Col from @tbl2Can you provide sample data, table structures and expected output? |
 |
|
|
|
|
|
|
|