| Author |
Topic |
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2009-05-20 : 02:12:04
|
| hi....i have been using CAST(@a as char(10))as the replacement of RPAD in oracle...is there any possible to print out null value of @a?? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-20 : 02:14:59
|
you can't print out a NULL value. NULL is unknownif @a is nullbegin print '@a is null'end KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2009-05-20 : 02:18:42
|
| aiks, i been doing that...nvm...thx alot...^^ |
 |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2009-05-21 : 03:39:03
|
| if @a is nullbegin print '@a is null'endis there anyway to print all column NULL instead of check each column? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-21 : 04:45:24
|
you mean this ?select isnull(somecol, 'this is a null column')from yourtable provided that your col is a string datatype KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2009-05-21 : 05:02:32
|
| erm i mean...sometime in table there are some column of data are NULL valueinstead of checking every column, likeif @column1 IS NULLset @column1 = ' 'is there any more general way to continue printprint cast(@column1 as char(10))Result*NULL value*coz is there is any null value in that line, whole line data will gone missing |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-21 : 06:15:36
|
quote: coz is there is any null value in that line, whole line data will gone missing
what do you mean by that ? are you concatenate this column with other columns ? you can use isnull() to return empty string when it nullexampleisnull(column1, '') + isnull(column2, '') + isnull(column3, '') KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
jholovacs
Posting Yak Master
163 Posts |
Posted - 2009-05-21 : 10:25:33
|
how about this?print cast(isnull(@column1, '') as char(10)) SELECT TOP 1 w.[name]FROM dbo.women wINNER JOIN dbo.inlaws i ON i.inlaw_id = w.parent_idWHERE i.net_worth > 10000000 AND i.status IN ('dead', 'dying') AND w.husband_id IS NULLORDER BY w.hotness_factor DESC |
 |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2009-05-22 : 00:27:40
|
| erm..i mean that is anything like a detecting null and change the null value to '-'like it will detect every print job and when it found NUll, it will change to '-' |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-05-22 : 00:30:33
|
quote: Originally posted by waterduck erm..i mean that is anything like a detecting null and change the null value to '-'like it will detect every print job and when it found NUll, it will change to '-'
You have to do it for every column where there is a possibility of NULL value using ISNULL() or COALESCE() or CASE statement KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2009-05-22 : 03:10:52
|
| >"< too bad.... |
 |
|
|
|