sql中如何设置存储过程的默认值为当前日期
createprocproc_borrow@willdatedatetime=dateadd(yy,-1,GETDATE()),@retumdatedatetime=GE...
create proc proc_borrow
@willdate datetime=dateadd(yy,-1,GETDATE()),@retumdate datetime=GETDATE()
as
select * from Borrow where WillDate between @willdate and @retumdate
go 展开
@willdate datetime=dateadd(yy,-1,GETDATE()),@retumdate datetime=GETDATE()
as
select * from Borrow where WillDate between @willdate and @retumdate
go 展开
3个回答
推荐于2017-08-12
展开全部
存储过程参数的默认值只允许常量和null. 可以做如下修改:
create proc proc_borrow
@willdate datetime=null,@retumdate datetime=null
as
select * from Borrow where WillDate between isnull(@willdate,dateadd(yy,-1,GETDATE())) and isnull(@retumdate,GETDATE())
go
展开全部
create proc proc_borrow
as
begin
declare @willdate datetime
declare @returndate datetime
SET @willdate = dateadd(yy,-1,GETDATE())
SET @returndate=GETDATE()
select * from Borrow where WillDate between @willdate and @returndate
end
go
as
begin
declare @willdate datetime
declare @returndate datetime
SET @willdate = dateadd(yy,-1,GETDATE())
SET @returndate=GETDATE()
select * from Borrow where WillDate between @willdate and @returndate
end
go
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
存储过程参数的默认值只允许常量和null. 可以做如下修改:
create proc proc_borrow
@willdate datetime=null,@retumdate datetime=null
as
select * from Borrow where WillDate between isnull(@willdate,dateadd(yy,-1,GETDATE())) and isnull(@retumdate,GETDATE())
go
create proc proc_borrow
@willdate datetime=null,@retumdate datetime=null
as
select * from Borrow where WillDate between isnull(@willdate,dateadd(yy,-1,GETDATE())) and isnull(@retumdate,GETDATE())
go
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询