The T-SQL Test

  • "I don't think too much, which is a little dis-heartening."

    Aww come on Steve, I think you are being too hard on yourself. Cheer up. It seems to me you do quite a bit of thinking. 😀

  • The answer is, "create a unique index on those columns!" 😛

    Well, so that will tell you if you have duplicates, but not which ones. Picky, picky.

    How about:

    select Convert( varchar, NumCol ) + ': ' + CharCol

    from TableUnderQuestion

    group by Convert( varchar, NumCol ) + ': ' + CharCol

    having Count(*) > 1;

    That will list out all dupes and it works for 2000 and 2005 (and probably 2008 as well). For extra credit, sneak in an 'order by'! (Not very much extra credit -- too easy.)

    Tomm Carr
    --
    Version Normal Form -- http://groups.google.com/group/vrdbms

Viewing 2 posts - 16 through 16 (of 16 total)

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