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 |
mohan123
Constraint Violating Yak Guru
252 Posts |
Posted - 2012-12-20 : 08:34:12
|
hello all,i have problem with string picking issue like chaitanya@yahoo.com in that one i need to pick first 3 characters and rest after @ like my output is cha@yahoo.com i have written query like this select SUBSTRING('chaitanya@symphonycorp.com',1,3)+'@'+Substring('chaitanya@symphonycorp.com',charindex('@','chaitanya@symphonycorp.com')+1,LEN('chaitanya@symphonycorp.com')) and output is coming fine but here i used 2 substring conditions and concatenated.How can i pull in single statement without concatenatingP.V.P.MOhan |
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2012-12-20 : 08:43:29
|
whats wrong with concatenating?How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-12-20 : 08:49:01
|
See this....DECLARE @str varchar(100)= 'chaitanya@symphonycorp.com'SELECT REPLACE (@str, SUBSTRING (@str, 4, charindex('@', @str, 4)-4), '')--Chandu |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-12-20 : 09:02:34
|
Same result as bandi, just different method with less purple wordsstuff(@str,4,patindex('%@%',@str)-4,'') JimEveryday I learn something that somebody else already knew |
|
|
mohan123
Constraint Violating Yak Guru
252 Posts |
Posted - 2012-12-20 : 09:53:20
|
yeah thanks a lot dudeP.V.P.MOhan |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2012-12-20 : 17:57:42
|
I don't think this works if the preamble is shorter than three characters.=================================================Hear the sledges with the bells - silver bells! What a world of merriment their melody foretells! |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-12-21 : 00:31:09
|
quote: Originally posted by mohan123 yeah thanks a lot dudeP.V.P.MOhan
Welcome--Chandu |
|
|
|
|
|
|
|