[英]Error converting datatype nvarchar to int
I am getting the error 我收到了错误
Error converting datatype nvarchar to int
将数据类型nvarchar转换为int时出错
Code: 码:
ALTER procedure [dbo].[sp_rcdoc]
@regno int,
@appname varchar(50),
@DOI datetime,
@COV varchar(50),
@validtill date,
@imgloc varchar(500),
@ImagNo char(20),
@Purposecode varchar(50),
@FLAG varchar(3)
AS BEGIN
IF NOT EXISTS(SELECT regno FROM tblRCDocuments WHERE regno = @regno)
BEGIN
INSERT INTO tblRCDocuments(regno, appname, DOI, COV, validtill, imgloc, ImagNo, Purposecode, FLAG)
VALUES(@regno, @appname, @DOI, @COV, @validtill, @imgloc, @ImagNo, @Purposecode, @FLAG)
END
Looks like regno is a nvarchar data type in your table and you have passed an int via your your procedure, either use a cast and convert @regno to an nvarchar or change the regno data type to an integer in the table. 看起来regno是表中的nvarchar数据类型,并且您已经通过您的过程传递了一个int,要么使用强制转换并将@regno转换为nvarchar,要么将regno数据类型更改为表中的整数。
DECLARE @regnocast NVARCHAR(15)
SET @regnocast = CAST(@regno AS NVARCHAR)
Then in your SELECT, INSERT and WHERE clauses use @regnocast rather than @regno 然后在SELECT,INSERT和WHERE子句中使用@regnocast而不是@regno
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.