无法将视图绑定到架构。自定义函数尚未绑定到架构。

在视图上创建索引,但视图调用了函数,需要将自定义函数绑定到架构。如何绑定,也是在函数上加一个with SCHEMABINDING

 1 --创建一个求季度的标量函数
 2 use House2
 3 go
 4 create function Ask_Quarter(@Q_id date)
 5 returns int with SCHEMABINDING
 6 as 
 7 begin
 8 declare @quarter int,@month int = MONTH(@Q_id)
 9 if(@month>=1 and @month<=3)
10      set @quarter = 1;
11 else if(@month>3 and @month<=6)
12      set @quarter = 2;
13 else if(@month>6 and @month<=9)
14      set @quarter = 3;
15 else
16      set @quarter = 4;
17      return @quarter;
18 end 
19 go

 

posted @ 2015-11-21 23:47  Spiderman.L  阅读(888)  评论(0编辑  收藏  举报