• Nevyn (4/28/2015)


    Sergiy (4/27/2015)


    MAC address - is it a string?

    By all means - NO!

    Compare E8:AB:... and e8-ab-...

    These are completely different strings, but they present the same MAC address.

    Just another example of an identifier which cannot be stored as a string.

    As much fun as it is to see people pushing back on Mr Celko, and as much as I may disagree with a few of his examples,

    create table #test

    (

    minimac varchar(5) PRIMARY KEY CLUSTERED

    )

    GO

    insert #test (minimac) values ('E8:AB')

    GO

    insert #test (minimac) values ('e8:ab')

    GO

    -- d r o p table #test

    Violation of PRIMARY KEY constraint 'PK__#test_____40C5B956C93DE1AB'. Cannot insert duplicate key in object 'dbo.#test'. The duplicate key value is (e8:ab).

    The strings aren't completely different as far as SQL server is concerned except with specific collations.

    Just sayin'

    You are only correct when you are using a case insensitive collation. The code above works just fine on my SQL 2012 DE instance where I use a case sensitive collation.