如何使用模式绑定创建存储过程? [英] How to create a stored procedure with schemabinding?

查看:32
本文介绍了如何使用模式绑定创建存储过程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用模式绑定创建存储过程,但我无法这样做.

I am trying to create a stored procedure with schemabinding but I am unable to do so.

错误:

为语句CREATE/ALTER PROCEDURE"指定了无效选项

An invalid option was specified for the statement "CREATE/ALTER PROCEDURE"

甚至可以创建具有模式绑定的存储过程吗?

Is it even possible to create stored procedures with schema binding?

create procedure dbo.proc_GetIncome  (
@fromdate datetime,  
@todate datetime  )
with schemabinding
as  
begin
declare @from varchar(8)  
declare @to varchar(8)  

select @from = YEAR(@fromdate) * 10000 +MONTH(@fromdate) * 100 +DAY(@fromdate)  
select @to = YEAR(@todate) * 10000 +MONTH(@todate) * 100 +DAY(@todate)  

select accountid , las.acctnm ,sum(amt) as Amount from nbfcledger led left join tbl_LASClientmaster las on led.AccountID=las.LasAcctNo  
  where glcode='INTRND' and dr_cr='d' and     
valuedate >= @from and valuedate <= @to  
group by accountid,las.acctnm   
end

推荐答案

架构绑定仅由 本机编译的存储过程 仅在 SQL Server 2014 中引入.

Schemabinding is only supported by, and required for, natively compiled stored procedures which were introduced only in SQL Server 2014.

这就是您在 SQL Server 2008 中收到错误的原因.

That is why you are getting the error in SQL Server 2008.

这篇关于如何使用模式绑定创建存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆