将nvarchar值'03/04/2013'转换为数据类型int时转换失败 [英] Conversion failed when converting the nvarchar value '03/04/2013' to data type int
问题描述
查询:
ALTER procedure get_validupto(@admin_id int)
as begin
DECLARE @NAME NVARCHAR(255)
if(select count(mac_id) from license_master where user_id=@admin_id)>0
begin
set @name=(select validupto from license_master where user_id=@admin_id)
return @name
end
else
set @name='false'
return @name
end
================================================== ================
输出:
运行[dbo].[get_validupto](@admin_id = 2).
将nvarchar值"03/04/2013"转换为数据类型int时,转换失败.
线程"01hw191161 \ c672c752-75c2-44 [53]"(0xfd4)已退出,代码为0(0x0).
没有受影响的行.
(返回0行)
@RETURN_VALUE =
完成运行[dbo].[get_validupto].
================================================== ==============
以varchar格式返回的值是"2013年4月3日" ...因此,我将收到此错误,为
将nvarchar值"03/04/2013"转换为数据类型int时转换失败."
==================================================================
output:
Running [dbo].[get_validupto] ( @admin_id = 2 ).
Conversion failed when converting the nvarchar value ''03/04/2013'' to data type int.
The thread ''01hw191161\c672c752-75c2-44 [53]'' (0xfd4) has exited with code 0 (0x0).
No rows affected.
(0 row(s) returned)
@RETURN_VALUE =
Finished running [dbo].[get_validupto].
=================================================================
returned value is ''04/03/2013''in varchar format... thn y i m getting this error as
"Conversion failed when converting the nvarchar value ''03/04/2013'' to data type int."
推荐答案
存储过程的返回值为整数.如果要将其他值返回给调用方,请使用输出参数或选择.
http://www.sqlteam.com/article/stored-procedures-returning-data [ ^ ]
The return for a stored procedure is an integer. If you want other values returned to the caller use an output parameter or a select.
http://www.sqlteam.com/article/stored-procedures-returning-data[^]
这篇关于将nvarchar值'03/04/2013'转换为数据类型int时转换失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!