T SQL - How can I get some data from a field or column in SQL table

Go To StackoverFlow.com

0

I need to get some data from a column.

For example I have data in a column like peter@msn.com. I want to get msn.com.

How I can I get that?

2012-04-05 19:46
by Peter


2

try this:

DECLARE @a VARCHAR(100) = 'peter@msn.com'
SELECT RIGHT(@a, LEN(@a) - CHARINDEX('@', @a))
2012-04-05 19:49
by Andrey Gurinov
Just be aware that if you use a function on a column that prevents sql server from using indexes. So if you try to find all the @msn.com email addresses you'll be looking at a table scan - Brian White 2012-04-05 21:16


0

SELECT SUBSTRING(Columnname,7,LEN(Columnname));
2012-04-05 19:47
by Teja
Thank you. It works, but I want generic @ sign, Not 7 as a constant number - Peter 2012-04-05 19:56
Ads