Home Forums SQL Server 2008 SQL Server Newbies Limiting list of values for a column from another table's column RE: Limiting list of values for a column from another table's column

  • aeri_q (10/26/2013)


    What i want, is a check like this, to be applied on NO_RANGE column of ASSET_CLASS at the time of insertion:

    CHECK (LIST IN (SELECT NO_RANGE FROM RANGE WHERE ACCNT_TYP = 'A')

    thus, No_RANGE in ASSET_CLASS can hold only those NO_RANGES which exist in RANGE table and have an ACCNT_TYP = 'A'.

    Check this link out http://stackoverflow.com/questions/13000698/sub-queries-in-check-constraint.

    I think that pretty much covers what you are trying to do.

    Even though the SQL Standard says you can do what you are trying to do, MSSQL says otherwise that this point.

    __________________________________________________________________________________________________________
    How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/