Sql server 2008R2 - 阻塞日期参数 [英] Sql server 2008R2 - choking on date parameter
问题描述
我正在尝试在SQL查询中执行此操作:
I'm trying to do this in a sql query:
exec [dbo].[sp_MyStoredProc] '1513837107', '2017-04-31', 6000, 1.0
存储的proc有以下原型:
The stored proc in question has the following prototype:
ALTER PROCEDURE [dbo].[sp_MyStoredProc]
(
@identifier nvarchar(50),
@desiredEndDate date,
@newTarget int,
@newDiscount float
)
当我尝试使用上面显示的exec行时,我收到以下错误:
错误将数据类型varchar转换为日期。
我之前从未遇到过这样的问题。为什么我不能这样做?我的日期字符串是默认的ISO格式之一。我很茫然。
当你 exec
'时你不能使用函数调用在查询中存储过程。
我尝试过:
我尝试将 @desiredEndDate
参数更改为 datetime
,甚至尝试指定完整的 datetime
字符串。似乎没什么用。
我也尝试将 datetime
参数设为 varchar
并在存储过程中转换,但失败并出现相同的错误。
When I try to use the "exec" line shown above, I get the following error:
Error converting data type varchar to date.
I've never had a problem like this before. Why can't I do this? My date string is in one of the default recognized ISO formats. I'm at a loss.
You can't use a function call when you're exec
'ing a stored proc in a query.
What I have tried:
I tried changing the @desiredEndDate
parameter to a datetime
and even tried specifying a complete datetime
string. Nothing seems to work.
I also tried making the datetime
parameter a varchar
and converting in the store proc, but that failed with the same error.
推荐答案
'2017-04-31'
这篇关于Sql server 2008R2 - 阻塞日期参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!