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.
| Author |
Topic |
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-02-23 : 11:26:55
|
| I'm sorry to repost this, but I didn't get an answer yet for this seemingly simple issue. I need to make sure that an email address has the @ symbol before I insert it from one table to another. Does anyone know the syntax? What I have that isn't working is -select * from table where email charindex ('@',email) > 0 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2006-02-23 : 11:43:36
|
| [code]select * from table where email like '%@%'[/code]maybe.. |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-02-23 : 12:13:42
|
btw, your original statement would work as well. Just a syntax problem (I hope your table isn't really named "table") select * from [table] where email charindex ('@',email) > 0Be One with the OptimizerTG |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2006-02-23 : 12:15:03
|
I should pay more attention.. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-02-23 : 14:04:40
|
| select * from table where email like '%@%' AND email NOT like '%@%@%' ???Kristen |
 |
|
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-02-23 : 16:58:35
|
| Got it Thx!!select * from table where email charindex ('@',email) > 0 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-24 : 01:39:35
|
quote: Originally posted by gemispence Got it Thx!!select * from table where email charindex ('@',email) > 0
Again you used emailselect * from table where email charindex ('@',email) > 0MadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-02-24 : 01:44:46
|
| Also not sure why you are using the function charindex here - it will be less efficient than using a test directly on the column won't it?Such as:select * from table where email like '%@%' AND email NOT like '%@%@%'The second bit, in blue, is optional - either your Email addresses are "clean" or they aren't - and if they aren't you need a much stronger test than just "contains @ sign" !!Kristen |
 |
|
|
|
|
|