• Matt:

    Your test doesn't quite do it:

    set ansi_padding on

    go

    create table #T(k varchar(10) primary key clustered)

    insert #T

    select 'a' union all

    select 'a ' union all

    select 'a ' union all

    select 'a ' union all

    select 'a '

    (ANSI_PADDING definitely on.)

    Msg 2627, Level 14, State 1, Line 3

    Violation of PRIMARY KEY constraint 'PK__#T________________23AA061E'. Cannot insert duplicate key in object 'dbo.#T'.

    The statement has been terminated.

    Is the result.

    For varchar fields, SQL still considers them equal if they would be equal without trailing spaces, regardless of this setting.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon