• actually ... the correct answer may not be that correct at all :hehe:

    It all depends on your ANSI_PADDING setting in use.

    set ansi_padding off ;

    declare @Vchar varchar(12)='prasad '

    , @Char char(12)='prasad '

    select len(@Vchar)

    , len(@Char)

    , len(reverse(@Vchar))

    , len(reverse(@Char))

    Result:

    ----------- ----------- ----------- -----------

    6 6 8 6

    (1 row(s) affected)

    But, as stated in BOL for SQL2012:

    In a future version of Microsoft SQL Server ANSI_PADDING will always be ON and any applications that explicitly set the option to OFF will produce an error. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

    So the questions correct answer can still be accepted as valid after all.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me