deal with char

  • Hi

    i want to have one char from filed with data (nvarchar(50))

    how can i do that;

     

  • An example please - of data and char to be extracted...

    for instance if you're looking for 's' in a string, you'd do something like this:

    declare @string nvarchar(50)

    set @string = 'abcdefghijklmnopqrstuvwxyz'

    select substring(@string, charindex('s', @string), 1)







    **ASCII stupid question, get a stupid ANSI !!!**

  • ok

    first filed @cul1 ='000000011111000'

    i want to extract the number of  first appear of '1' to fill it in another column

    thanks 

  • If I understand you correctly, you want the position of the first occurence of '1' in your string...if so, then..

    declare @string nvarchar(50)

    declare @position tinyInt

    set @string = '000000011111000'

    set @position = charindex('1', @string)

    print @position







    **ASCII stupid question, get a stupid ANSI !!!**

Viewing 4 posts - 1 through 3 (of 3 total)

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