如何解决此错误'将数据类型nvarchar转换为float。'使用存储过程在sql中插入记录时 [英] How to solve this Error ' converting data type nvarchar to float.' while inserting a record in sql using stored Procedure

查看:81
本文介绍了如何解决此错误'将数据类型nvarchar转换为float。'使用存储过程在sql中插入记录时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误'将数据类型nvarchar转换为float时出错。'使用存储过程在表中插入记录时。



我的存储过程是



I am getting error 'Error converting data type nvarchar to float.' while inserting a record in the table using stored procedure.

My stored Procedure is

USE [ezNew_db]
GO
/****** Object:  StoredProcedure [vipl-user].[SP_Copy_Bill_InsertData]    Script Date: 01/06/2015 09:31:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [vipl-user].[SP_Copy_Bill_InsertData](@tablename nvarchar(50)  ,@INV_NO nvarchar(50),@AC_NO nvarchar(50),@AC_NAME nvarchar(255),@INV_DATE nvarchar(50),@AD1 nvarchar(255),@AD2 nvarchar(255),@AD3 nvarchar(255),@AD4 nvarchar(255),@AD5 nvarchar(255),@AD6 nvarchar(255),@TERMS nvarchar(30),@EXCHANGE_RATE float,@CREATED_BY nvarchar(10),@DATE_CREATED nvarchar(50),@ZERO_RATED_INV bit,@TAX_INCLUDE bit,@Deleted bit,@SEAL_NO nvarchar(50),@JOB_NO nvarchar(255),@Inv_Amt nvarchar(50),@GST nvarchar(50),@Inv_Net nvarchar(50),@Status nvarchar(50)) as
begin
Declare @sql nvarchar(max)
set @sql='insert into '+@tablename+'([INV_NO],[AC_NO],[AC_NAME],[INV_DATE],[AD1],[AD2],[AD3],[AD4],[AD5],[AD6],[TERMS],[EXCHANGE_RATE],[CREATED_BY],[DATE_CREATED],[ZERO_RATED_INV],[TAX_INCLUDE],[Deleted],[SEAL_NO],JOB_NO,Inv_Amt,GST,Inv_Net,Status) values ('''+@INV_NO+''','''+@AC_NO+''','''+@AC_NAME+''','+CAST(@INV_DATE as varchar(50))+','''+@AD1+''','''+@AD2+''','''+@AD3+''','''+@AD4+''','''+@AD5+''','''+@AD6+''','''+@TERMS+''','''+CAST(@EXCHANGE_RATE as float)+''','''+@CREATED_BY+''','+CAST(@DATE_CREATED as varchar(50))+','+CAST(@ZERO_RATED_INV as CHAR(1))+','+CAST(@TAX_INCLUDE as CHAR(1))+','+CAST(@Deleted as CHAR(1))+','''+@SEAL_NO+''','''+@JOB_NO+''','+CAST(@Inv_Amt as decimal)+','+CAST(@GST as decimal)+','+CAST(@Inv_Net as decimal)+','''+@Status+''')'
exec(@sql)
end





我在3层进行我的项目我把BEL中的Exchangerate字段作为float / decimal。



请你解决这个错误。



I am doing my project in 3 tier I have taken Exchangerate field in BEL as float/decimal.

Would you Please resolve this error.

推荐答案

我想,有一个数据类型为FLOAT i的列在您的表中,您正在将STRING数据插入该列。

您可以格式化脚本以使其更具可读性。你也可以在网上使用。

poorsql
I guess, there is a column with datatype FLOAT in your table and you are inserting STRING data to that column.
You can format the script to make it more readable. You can use below online too.
poorsql


你正在通过 varchar 进入 float 字段。


这篇关于如何解决此错误'将数据类型nvarchar转换为float。'使用存储过程在sql中插入记录时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆