• I have to admit that I have no idea how to check it using the GUI, and I don't know where you got the data. In any case the code and the remarks bellow show you what I meant. Also notice that there could be other reasons for this behavior, but without other details (for example the view's defenetion, tables' size etc') it will be very hard to know the reason that you don't get the table elimination.

    USE AdventureWorks

    go

    --The query does a join on 2 tables, but if you'll chec the query plan, you'll see that includes only 1.

    --This is because there is a foreign key constraints between the tables, so there can not be a record

    --in SalesOrderDetail without a corosponding record in SalesOrderHeader table

    SELECT SOD.*

    FROM Sales.SalesOrderDetail SOD inner join Sales.SalesOrderHeader SOH ON SOD.SalesOrderID = SOH.SalesOrderID

    --check the constraint that is called FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID

    exec sp_helpconstraint 'Sales.SalesOrderDetail'

    --Now lets change the constraint and "deactivate" it. We can update or insert data that vaiolate the constraint.

    alter table Sales.SalesOrderDetail nocheck constraint FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID

    --Check the query plan now. It will be different, because the constraint can not be trusted anymore

    SELECT SOD.*

    FROM Sales.SalesOrderDetail SOD inner join Sales.SalesOrderHeader SOH ON SOD.SalesOrderID = SOH.SalesOrderID

    --Enabling the constraint agian and checking the query plan again

    alter table Sales.SalesOrderDetail check constraint FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID

    go

    --After we enabled the constraint again, we still have a query plan that checks both tables.

    --This is because the constrain is still untrusted. We are not able to modify data that will

    --violate the constraint, but we need to check if the data that is already in the talbe meets the

    --constraint's criteria

    SELECT SOD.*

    FROM Sales.SalesOrderDetail SOD inner join Sales.SalesOrderHeader SOH ON SOD.SalesOrderID = SOH.SalesOrderID

    --Checking if the constraint is trusted

    --The constraint is not trusted

    select objectproperty(object_id,'CnstIsNotTrusted')

    from sys.objects

    where name = 'FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID'

    --Enabling the constraint agian, but this time also check the data that is already in the table

    alter table Sales.SalesOrderDetail WITH CHECK check constraint FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID

    go

    --Now the query plan acesses only 1 table again

    SELECT SOD.*

    FROM Sales.SalesOrderDetail SOD inner join Sales.SalesOrderHeader SOH ON SOD.SalesOrderID = SOH.SalesOrderID

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/