写了一个存储过程,在执行报‘从字符串向 datetime 转换时失败。’ 请教高手解答不胜感激! 10
附代码:setANSI_NULLSONsetQUOTED_IDENTIFIERONGOcreateprocedure[dbo].[P_TJWORK](@startDate...
附代码:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[P_TJWORK]
(
@startDate datetime='SELECT DATEADD(DD,-DAY(GETDATE())+1,GETDATE())', --起始日期
@endDate datetime='SELECT DATEADD(DD,-DAY(DATEADD(M,1,GETDATE())),DATEADD(M,1,GETDATE()))' --结算结束日期
)
as
insert into TJWORK Select KSBM.KSlabel,Count(distinct JCSFXM.ID),Sum(JCSFXM.YJE),getdate()
From JCSFXM Left Outer Join SFXM On JCSFXM.SFXMDM=SFXM.SFXMDM Left Outer Join JCXX On JCSFXM.ID=JCXX.ID Left Outer JOIN KSBM ON SFXM.KSBM=KSBM.ksbm
where JCSFXM.SFBJ='1' and
JCSFXM.JCRQ>=@startDate and JCSFXM.JCRQ<=@endDate
Group By KSBM.KSlabel 展开
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
create procedure [dbo].[P_TJWORK]
(
@startDate datetime='SELECT DATEADD(DD,-DAY(GETDATE())+1,GETDATE())', --起始日期
@endDate datetime='SELECT DATEADD(DD,-DAY(DATEADD(M,1,GETDATE())),DATEADD(M,1,GETDATE()))' --结算结束日期
)
as
insert into TJWORK Select KSBM.KSlabel,Count(distinct JCSFXM.ID),Sum(JCSFXM.YJE),getdate()
From JCSFXM Left Outer Join SFXM On JCSFXM.SFXMDM=SFXM.SFXMDM Left Outer Join JCXX On JCSFXM.ID=JCXX.ID Left Outer JOIN KSBM ON SFXM.KSBM=KSBM.ksbm
where JCSFXM.SFBJ='1' and
JCSFXM.JCRQ>=@startDate and JCSFXM.JCRQ<=@endDate
Group By KSBM.KSlabel 展开
2015-06-27
展开全部
需要先将@n转成字符串,才能拼字符串。
或是,你把@n 定义成字符类型。
或是,你把@n 定义成字符类型。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询