urgent please

  • i have table a with two columns..

    Testtable

    vai1 int

    vai2 varchar(50)

    values

    vai1 =1

    vai2= 1234,578

    select substring(vai2,charindex(',',vai2),len((vai2)- convert(int,(charindex(',',vai2))))) from testvai where vai1=1

    i want to retrive the value 578

    please help me on this..

  • Based solely on your post the following code works:

    create table #TestTable(

    vai1 int,

    vai2 varchar(50)

    );

    insert into #TestTable

    select 1,'1234,578';

    select

    right(vai2, len(vai2) - charindex(',',vai2))

    from

    #TestTable

    where

    vai1 = 1;

    drop table #TestTable;

    Next question, what are you trying to accomplish and is the data you posted reflective of all your data?

  • i got the expected result by following query...

    select substring(vai2,charindex(',',vai2)+1,len(vai2)- convert(int,(charindex(',',vai2)))) from testvai where vai1=2

    is ther any simpler way..

    Please help me..

  • THank you very much..

    i got the same result in a simpler way..

    select right(vai2, len(vai2) - charindex(',',vai2)) from testvai where vai1=2

    Thankq for the quick reply..

  • declare @str1 varchar(10)

    set @str1='1234,578'

    select right(@str1,len(@str1)-charindex(',',@str1))

    output

    ----------

    578

    (1 row(s) affected)



    Pradeep Singh

  • i was so slow!!



    Pradeep Singh

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply