ANSI_PADDING

  • Superb question.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Thanks for all of the compliments everyone.

    I ran into this scenario and as it seemed contradictory to common sense to me, I figured I'd see if I was the only one who thought that.

    Given 2/3 rds of responders got it wrong, I guess not. :w00t:

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • Nice one, thank you

    Iulian

  • Good question, thanks for submitting.

    http://brittcluff.blogspot.com/

  • tks - great question

  • I did it but it returns 4,4,3. So the answer was wrong!

    set ansi_padding on;

    go

    create table #q (v varchar(5) );

    go

    insert into #q

    select 'ABC' UNION ALL

    select 'ABC ' UNION ALL

    select 'ABC ' UNION ALL

    select 'ABC '

    select * from #q

    select COUNT(*) from #q where v = 'ABC';

    select COUNT(*) from #q where v = 'ABC ';

    select COUNT(*) from #q where v LIKE 'ABC ';

    drop table #q

    go

  • Pawel Borkowski (12/22/2011)


    I did it but it returns 4,4,3.

    You might want to double check the code you typed, and compare it to the code in the original question. Pay extra attention to the number of trailing and leading spaces.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • How to count spaces on the image? !#$%!$^@#$%@!

    Can you tell me what was the right count of spaces in this example?

  • Pawel Borkowski (12/22/2011)


    How to count spaces on the image? !#$%!$^@#$%@!

    Can you tell me what was the right count of spaces in this example?

    insert into #q

    select 'ABC' UNION ALL

    select 'ABC ' UNION ALL

    select 'ABC ' UNION ALL

    select ' ABC '

  • So I lost the space before 🙂

    It changes everything! :w00t:

    Thx

  • Interesting question. Thanks.

Viewing 11 posts - 16 through 25 (of 25 total)

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