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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to find a position in a string and LTRIM

Author  Topic 

demonbane
Starting Member

10 Posts

Posted - 2003-07-03 : 20:33:28
You guys have helped me many times in the past; for that thanks. I am hopeing you can help me out again. I know is this simple and I've done it before, but for the life of me, I can't remember.

This is the problem.

I have a table called junk_senders with a column named junk_senders.
This table contains email address from anyone that sends me spam.
I would like to start blocking entire domains instead of individial email addresses. I would like to remove everything left of the @ symbol including the symbol. For example: 123@123.com would be trimed to 123.com.

So I guess I have to search the string for the @ symbol add one and left trim everything. At least that is what my fuzzy logic tells me.

Does anyone have any suggestions or examples I can look at.
Thanks
Jerry

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2003-07-03 : 20:59:00
Jerry,

The help file that comes with SQL Server has all the information you need. It is commonly referred to as BOL (Books On Line).


--There are many ways to do this
DECLARE @Data VARCHAR(50)
SET @Data = '123@123.com'
SELECT RIGHT(@Data, LEN(@Data)-CHARINDEX('@',@Data))
SELECT SUBSTRING(@Data, CHARINDEX('@',@Data)+1, LEN(@Data))


Look up all the keywords in BOL for more info...

DavidM

"SQL-3 is an abomination.."
Go to Top of Page

demonbane
Starting Member

10 Posts

Posted - 2003-07-04 : 12:14:14
Thank you byrmol, that is what I needed. Now I just wish outlook's junk sender spam filter would have an odbc connetion to my database. Then things would be great.

Anyways, thanks for helping me with my personal little query. Thanks
Jerry


Go to Top of Page
   

- Advertisement -