August 12, 2008 at 1:29 pm
Hello everybody,
I have a terrible problem.
I have a members table with email field is optional. I'm trying to list the domainnames of the email field, but I got
"Invalid length parameter passed to the RIGHT function. " error.
What do you suggest?
My code;
SELECT RIGHT(email, CHARINDEX('@', REVERSE(Email))-1) AS domain, COUNT(Email) AS numberofperson FROM Members GROUP BY RIGHT(Email, CHARINDEX('@', REVERSE(Email))-1) ORDER BY numberofperson DESC, domain
August 12, 2008 at 1:31 pm
Add "WHERE EMAIL IS NOT NULL or Charindex('@', Email) > 0"
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 12, 2008 at 10:57 pm
Jack Corbett (8/12/2008)
Add "WHERE EMAIL IS NOT NULL or Charindex('@', Email) > 0"
nope, this doesn't work neither..
error is the same;
"Invalid length parameter passed to the RIGHT function."
August 13, 2008 at 5:16 am
That's interesting because the error is because you are not finding the '@' in an email address so the -1 is causing you to get an negative for the length parameter of the Right Function. Try using CharIndex('@', Reverse(email)) > 0 which duplicates the logic in your RIGHT.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply