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
 General SQL Server Forums
 New to SQL Server Programming
 question with conversion

Author  Topic 

midpenntech
Posting Yak Master

137 Posts

Posted - 2009-04-20 : 10:43:54
I have a line of code I am trying to say Case when one date is null and another date is null don't show cust name.

Here is the code

Case when eqponrdt = 'Null' and apdateons = 'Null' Then custmast.custname = 'NULL'

This does not work and I am trying to figure out why the error code is conversion failed when converting datetime from char string. Any help would be greatly appreciated

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-04-20 : 10:50:18
Case when eqponrdt IS NULL and apdateons IS NULL Then custmast.custname = ''
Go to Top of Page

midpenntech
Posting Yak Master

137 Posts

Posted - 2009-04-20 : 11:02:05
comes up with '=' incorrect syntax
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-20 : 11:40:28
I guess this is part of a SELECT query?

SELECT *
Case when eqponrdt IS NULL and apdateons IS NULL Then '' else custmast.custname end AS custname
from table1




E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2009-04-20 : 11:40:43
Close but no cigar!

CASE WHEN eqponrdt IS NULL and apdateons IS NULL THEN '' END


NB :: Damn -- PESO -- quicker by a few seconds!

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -