• Sean Lange (10/25/2013)


    p.shabbir (10/25/2013)


    Sean Lange (10/25/2013)


    p.shabbir (10/25/2013)


    Hi Scuby,

    Try this.

    select REPLACE(SUBSTRING(Your_Column,1,CHARINDEX('@',Your_Column)),'@','') Name from Your_Table NOLOCK

    Thanks

    sibi.

    Why NOLOCK???

    Sean,

    At my work i used to specify "NOLOCK" at the end of select statement.Hence, by habit i mentioned there.You can take out that.

    I would suggest that is a habit you learn to break unless you fully understand all the nasty stuff that hint brings to the table.

    http://sqlblogcasts.com/blogs/tonyrogerson/archive/2006/11/10/1280.aspx

    http://blogs.msdn.com/b/davidlean/archive/2009/04/06/sql-server-nolock-hint-other-poor-ideas.aspx

    http://www.jasonstrate.com/2012/06/the-side-effect-of-nolock/[/url]

    And i checked your query.

    Only this is statement is working.

    REPLACE(SUBSTRING(SEmail_Addr,1,CHARINDEX('@',SEmail_Addr)),'@','').

    For other two got this error.

    Error : Invalid length parameter passed to the LEFT or SUBSTRING function.

    That's odd. The code I posted works perfectly. Now if you have email values that don't have an @ it would not work where the find code you posted does. I merely posted a couple of alternative ways. In now way did I mean that your fine code was not sufficient. In fact, I had yours in my list of possibilities.

    Thanks for the links and your query is working perfectly.

    I was running the statements individually.

    Thanks.