繁体   English   中英

如何使用schemabinding创建存储过程?

[英]How to create a stored procedure with schemabinding?

我试图用schemabinding创建一个存储过程,但我无法这样做。

错误:

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

甚至可以使用模式绑定创建存储过程吗?

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中引入的本机编译存储过程支持并且必需的模式绑定。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM