开发者

convert in stored procedure call?

I have the following piece of SQL that does not work:

declare @id INT; 
set @id=0; 
exec insert_mail @id OUTPUT, 'ZLgeOZlqRGC6l57TyD/xYQ==', 4928, '2010\01\14\14\03131_2.eml', 'Suz, Katie and Kourtney''s Housewarming Party', CONVERT(DATETIME, '2015-01-18 14:03:13', 120); 
select @id;

and changing it this way fixes it:

declare @id INT; 
set @id=0; 
declare @p_valid_until datetime;
set @p_valid_until=CONVERT(DATETIME, '2015-01-18  14:03:13', 120)
exec insert_mail @id OUTPUT, 'ZLgeOZlqRGC6l57TyD/xYQ=='开发者_Python百科, 4928, '2010\01\14\14\03131_2.eml', 'Suz,  Katie and Kourtney''s Housewarming Party', @p_valid_until; 
select @id;

Anybody can explain?

Cheers, Jan


You can't call functions in the passing of arguments. These parameter values are expected to be constants or parameters.


You can't pass functions, etc. to stored procedures, only variables or constant values...


In the first case you are calling the CONVERT function in an execute command which is not allowed. You can't call functions in the passing of arguments

EXECUTE insert_mail ... CONVERT(DATETIME, '2015-01-18 14:03:13', 120)

I don't see the point of using the convert function. Just type date in without convert.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜