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 |
ldrenning
Starting Member
23 Posts |
Posted - 2006-05-31 : 11:13:38
|
Is there a way in SQL Server to query for a character that is in a field? ... I have this old table before there was form validation, and I want to get the addresses out of the column that actually have an @.I want to do something like this.SELECT emailFROM xyzWHERE email contains '@'AND email contains '.'any ideas? Will this work?Thanks,-L |
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2006-05-31 : 11:19:17
|
You will use the LIKE function for this:SELECT email FROM xyz WHERE email LIKE '%@%'SQL Server Helperhttp://www.sql-server-helper.com |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2006-05-31 : 11:19:59
|
You could do similar, if your column is full text indexed -USE NorthwindGOSELECT ProductNameFROM ProductsWHERE CONTAINS(ProductName, ' "choc*" ')GOotherwise you'd be looking at charindex -SELECT CHARINDEX ('@', columnname) FROM yourtableOR in your caseSELECT * from yourtableWHERE CHARINDEX ('@', columnname) > 0-------Moo. :) |
|
|
ldrenning
Starting Member
23 Posts |
Posted - 2006-05-31 : 11:24:20
|
Thanks everyone! |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-31 : 11:30:04
|
http://vyaskn.tripod.com/handling_email_addresses_in_sql_server.htmMadhivananFailing to plan is Planning to fail |
|
|
|
|
|