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 |
|
Antinsh
Starting Member
16 Posts |
Posted - 2008-05-21 : 09:24:57
|
| Can someone tell me why this thing in the end return Null?declare @uz_id uniqueidentifierset @uz_id=nullset @uz_id= case @Uz_ID when null then '00000000-0000-0000-0000-000000000000' else @Uz_ID endselect @uz_id...it should return '00000000-0000-0000-0000-000000000000' in my opintionP.S. When I say return i mean the value that is shown after 'select @uz_id' is executed:) |
|
|
PeterNeo
Constraint Violating Yak Guru
357 Posts |
Posted - 2008-05-21 : 09:33:06
|
| change u r case tocase when @Uz_ID is null then |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-05-21 : 09:34:05
|
| declare @uz_id uniqueidentifierset @uz_id=nullset @uz_id=case when @Uz_ID is null then '00000000-0000-0000-0000-000000000000'else @Uz_IDendselect @uz_idMadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-21 : 09:34:23
|
In my humble opinion, the code above should return NULL.Why? Because you can't check for NULL that way.Try thisdeclare @uz_id uniqueidentifierset @uz_id = nullset @uz_id = case when @Uz_ID is null then '00000000-0000-0000-0000-000000000000' else @Uz_ID endselect @uz_id E 12°55'05.25"N 56°04'39.16" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-05-21 : 09:34:53
|
 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-05-21 : 09:35:16
|
MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|