在视图上创建索引,但视图调用了函数,需要将自定义函数绑定到架构。如何绑定,也是在函数上加一个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

 

相关文章:

  • 2021-09-20
  • 2021-12-05
  • 2022-02-08
  • 2021-11-13
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-30
  • 2021-12-23
  • 2021-10-11
  • 2021-08-06
  • 2021-10-11
相关资源
相似解决方案