What to replace left join in a view so i can have an indexed view?

后端 未结 5 1377
既然无缘
既然无缘 2020-12-31 00:43

I have normalized tables in a database and to denormalize it, I created a view out of two tables. When I tried to create a clustered index on the view, it wouldn\'t let me,

5条回答
  •  佛祖请我去吃肉
    2020-12-31 01:20

    There is a "workaround" here that involves check for NULL in the join and having a NULL representation value in the table

    NULL value

    INSERT INTO Father (Father_id, Father_name) values(-255,'No father')
    

    The join

    JOIN [dbo].[son] s on isnull(s.father_id, -255) = f.father_id
    

提交回复
热议问题