赞美是成功的,但是当我执行此代码时,它显示错误"关键字' BEGIN'"附近的语法不正确..并且可能是以下代码
SET @TEMPSELECT=(SELECT Cast(Abs(Datediff(day, @EndDate, @StartDate)) AS VARCHAR(100)) AS day)
PRINT @TEMPSELECT
答案 0 :(得分:0)
试试这个,
CREATE PROCEDURE Prc_datechecking
AS
BEGIN
DECLARE @StartDate DATETIME='04/07/2015',
@EndDate DATETIME='04/09/2015',
@TEMPSELECT NVARCHAR(50)=''
SET @TEMPSELECT=(SELECT Cast(Abs(Datediff(day, @EndDate, @StartDate)) AS VARCHAR(100)) AS day)
PRINT @TEMPSELECT
END
EXEC Prc_datechecking
这在SQL Server 2012中运行良好