Solved

Error using FLOAT datatype in Injected Stored Procedure

Posted on 2010-11-19
3
364 Views
Last Modified: 2012-05-10
I have a syntax error below running the query? Is there something special I need when injecting column other than type varchar into a stored procedure? thanks

Msg 8114, Level 16, State 5, Line 20
Error converting data type varchar to float.

SELECT * from FX

declare @Proc nvarchar(50)
declare @RowCnt int
declare @MaxRows int
declare @ExecSql nvarchar(255)
select @RowCnt = 1
select @Proc = 'fx_save'
declare @TransactionName varchar(30) = 'Update FX Rates';

-- get source data to inject into stored Proc
declare @FXImport table (p_fx int,currency1 varchar(50),currency2 varchar(50),rate float(53),
                         date datetime,isdeleted bit,createdby varchar(64),created datetime,updated datetime,updatedby nvarchar(30))
insert into @FXImport (p_fx,currency1,currency2,rate,date,isdeleted,createdby,created,updated,updatedby) select * from fx where isdeleted = 0 order by created desc

select @MaxRows=count(*) from @FXImport
-- loop through source and call SP for each row. SP will recalculate cross rate which is why I am calling SP
BEGIN TRAN @TransactionName
      while @RowCnt <= @MaxRows
      begin
            select @ExecSql = 'exec ' + @Proc + ' ''' + currency1 + ' ''' + currency2 + ' ''' + rate + ' ''' + date + ' ''' from @FXImport
            execute sp_executesql @ExecSql
            SET @RowCnt = @RowCnt + 1
      end
SELECT * from FX
ROLLBACK TRAN @TransactionName
-- COMMIT TRAN @TransactionName
0
Comment
Question by:Mez4343
3 Comments
 
LVL 5

Expert Comment

by:Zopilote
ID: 34175833
could it be that you are using a comma (,) as a decimal ppoint for currency1 for currency2?
0
 
LVL 10

Author Comment

by:Mez4343
ID: 34176448
No, currency 1 and 2 values would be: USD or EUR not money.
0
 
LVL 3

Accepted Solution

by:
DFW_Ed earned 250 total points
ID: 34177240
can't seem to get my answer to submit.  trying attachment FloatDatatypeAnswer.txt
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now