Author |
Topic |
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2009-06-15 : 00:30:12
|
Hi I have a column which is of GUID type and of nullable type.I need to do null check for this column of guid type.Is this the proper way to do null check for GUID data type:IsNUll(employee.empid,NULL)here empid is a GUID valuesusan |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-15 : 01:17:40
|
No that is not to check if empid is null it is to replace the value of empid in case of null.select isnull(empid,666) would return 666 if empid is null for example.The check would beIF empid IS NULLorWHERE empid IS NULLGreetings Webfred No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-15 : 01:18:46
|
[code]where employee.empid is null[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2009-06-15 : 01:40:33
|
Suppose i want to return it blank value then how to replace it in null check because it will not accept the replacement with '' as it is not varchar it throws error during executionsusan |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-15 : 01:53:09
|
Can you show us an example in context what you're trying to do please? No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2009-06-15 : 01:58:11
|
this is what am trying to doselectISNULL(EMPLOYEE.EMPNAME,'') AS EMPLOYEE NAME,EMPLOYEE.EMPID AS EMPLOYEEIDINTO #EMPhere empname is varchar and empid is guid type and how to do null check for this guid typesusan |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-15 : 02:00:03
|
[code]isnull(convert(varchar(36), empid ), '')[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
susan_151615
Yak Posting Veteran
99 Posts |
Posted - 2009-06-15 : 02:09:26
|
No guid cant be converted into varchar type it will be not compatible in front end processotr even though it can be executed in sqlsusan |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-15 : 02:11:14
|
quote: Originally posted by susan_151615 No guid cant be converted into varchar type it will be not compatible in front end processotr even though it can be executed in sqlsusan
then handle the NULL value in your front end not in the query KH[spoiler]Time is always against us[/spoiler] |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-06-15 : 11:46:52
|
Maybe you want to do something like:COALESCE(empid, CAST('00000000-0000-0000-0000-000000000000' AS UNIQUEIDENTIFIER)) |
|
|
|