SQL Server VIEW results different to the SELECT

  • Help!

    I created below view

    ALTER VIEW [CubeView].[FCT_Asset_Maintenance_Work_Order_Dewey]

    AS

    SELECT f.FCT_Work_Order_Key,f.Work_Order_Num,f.Asset_Key

    FROM [dbo].[FCT_Asset_Maintenance_Work_Order] f

    INNER JOIN DIM_Asset a

    ON f.Asset_Key = a.Asset_Key

    ;

    go

    Then query the view, get different results to the same select query

    SELECT * FROM [CubeView].[FCT_Asset_Maintenance_Work_Order_Dewey]

    WHERE FCT_Work_Order_Key = 101057

    go

    return 2 rows which is wroing

    SELECT f.FCT_Work_Order_Key,f.Work_Order_Num,f.Asset_Key

    FROM [dbo].[FCT_Asset_Maintenance_Work_Order] f

    INNER JOIN DIM_Asset a

    ON f.Asset_Key = a.Asset_Key

    WHERE FCT_Work_Order_Key = 101057

    ;

    return 1 row which is correct!

    when I looking into to their execution plan, they are not the same.

  • Shouldn't be happening.

    Are you using the same database?

    I notice that you use schema [dbo] for one table and not for the other - is that a factor?

  • Post the actual execution plans for both runs as *.sqlplan files.

Viewing 3 posts - 1 through 2 (of 2 total)

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