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
 Using a not equal in SQL Case Expression

Author  Topic 

Rich75
Starting Member

8 Posts

Posted - 2013-07-22 : 17:14:42
The SUBSTRING function returns @domain.com. I don't want any results to be displayed from my sql statement if it equals @myemail.com. I have other cases too that are not relevant to my question. I'm getting an error that says invalid syntax near <

How can I fix this error? Thanks


SELECT DISTINCT CASE CUST_EMLAD_TX
WHEN SUBSTRING(CUST_EMLAD_TX, CHARINDEX('@',CUST_EMLAD_TX), LEN(CUST_EMLAD_TX)) <> '@myemail.com' THEN CUST_EMLAD_TX
END
FROM ...

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2013-07-22 : 17:25:12
[code]SELECT DISTINCT CASE
WHEN RIGHT(CUST_EMLAD_TX, 12) <> '@myemail.com' THEN CUST_EMLAD_TX
ELSE NULL
END
FROM ...[/code]


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

Rich75
Starting Member

8 Posts

Posted - 2013-07-22 : 19:58:24
quote:
Originally posted by SwePeso

SELECT DISTINCT	CASE
WHEN RIGHT(CUST_EMLAD_TX, 12) <> '@myemail.com' THEN CUST_EMLAD_TX
ELSE NULL
END
FROM ...



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA



I made a mistake. This works good. Thanks
Go to Top of Page
   

- Advertisement -