T- SQL Constraints

  • Comments posted to this topic are about the item T- SQL Constraints

    Thanks,
    Shiva N
    Database Consultant

  • Good Question.

    I do think the answer is a dead give away if you have familiarity with sys.objects though.

    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

  • SQLRNNR (7/30/2014)


    Good Question.

    I do think the answer is a dead give away if you have familiarity with sys.objects though.

    +1. Dead easy once you know which column you need.

    Still nice question.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • type_desc is Latin1_General_CI_AS_KS_WS

    So, also, in a "case sensitive" database type_desc LIKE '%cons%' returns data.

  • This was removed by the editor as SPAM

  • Stewart "Arturius" Campbell (7/31/2014)


    SQLRNNR (7/30/2014)


    Good Question.

    I do think the answer is a dead give away if you have familiarity with sys.objects though.

    +1

    Nice one, thanks Shiva

    +1

    Thanks

  • Koen Verbeeck (7/31/2014)


    SQLRNNR (7/30/2014)


    Good Question.

    I do think the answer is a dead give away if you have familiarity with sys.objects though.

    +1. Dead easy once you know which column you need.

    Still nice question.

    +1. It would have been a bit less obvious if more of the incorrect options had used type_desc, with only one option using it that was the only column of sys.objects anone had to know to pick the right answer.

    Tom

  • Koen Verbeeck (7/31/2014)


    SQLRNNR (7/30/2014)


    Good Question.

    I do think the answer is a dead give away if you have familiarity with sys.objects though.

    +1. Dead easy once you know which column you need.

    Still nice question.

    Agreed, but a good question that may spark learning if you don't know system tables. I think sys.objects is probably the best place to start.

  • Good question.

    +1.

    ---------------
    Mel. 😎

  • Why would I use the method in the question when, as the answer showed, I can use:

    SELECT *

    FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

  • Thomas Abraham (7/31/2014)


    Why would I use the method in the question when, as the answer showed, I can use:

    SELECT *

    FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS

    I generally use sys.objects for this kind of lookup. I seldom think of the information_schema tables. It's just quick and easy to hit sys.objects and I forget often about the info...schema ones.

    But it is also good to know a few different methods of retrieving the same information.

    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

  • Great question - thanks. I probably would have gotten it wrong had I not seen "type_desc" so many times before. 🙂

    - webrunner

    -------------------
    A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
    Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

  • Good question on sysobjects table. You could also have added a distinct to the select statement, so I would only get any table having multiple constraints only once.

  • William Vach (7/31/2014)


    Good question on sysobjects table. You could also have added a distinct to the select statement, so I would only get any table having multiple constraints only once.

    +1

    (but you know that... these sql statements are customizable) 😛

    ww; Raghu
    --
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.

  • Nice question. Thanks for sharing

Viewing 15 posts - 1 through 15 (of 15 total)

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