Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Using a not equal in SQL Case Expression
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Rich75
Starting Member

8 Posts

Posted - 07/22/2013 :  17:14:42  Show Profile  Reply with Quote
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

Sweden
30421 Posts

Posted - 07/22/2013 :  17:25:12  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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
Go to Top of Page

Rich75
Starting Member

8 Posts

Posted - 07/22/2013 :  19:58:24  Show Profile  Reply with Quote
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

Edited by - Rich75 on 07/22/2013 20:00:27
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000