日期存储过程

时间:2012-11-23 13:10:35

标签: sql-server

无法执行存储过程。在日期差异

    SELECT DATEDIFF(DAY,'2012-11-23',(exec AddValorDate 3,'2012-11-26'))
    Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'exec'.
    Msg 102, Level 15, State 1, Line 1
    Incorrect syntax near ')'.

2 个答案:

答案 0 :(得分:0)

您应该将AddValorDate设置为函数而不是存储过程。然后你可以在你的查询中调用它。

答案 1 :(得分:0)

如果无法将存储过程转换为函数,以下内容将解决您的问题。

声明@date表 (     日期时间 )

插入@date exec AddValorDate 3,'2012-11-26'

从@date选择DATEDIFF(DAY,'2012-11-23',theDate)

相关问题