473,385 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Inserting decimal values into the table using insert statements

Hello all,

i am trying to insert decimal data (i.e 3.2,4.5,6.8 )into table but receiving error: "Error converting data type varchar to numeric."

Here is the my code that i use to inserting values.

Expand|Select|Wrap|Line Numbers
  1. create table test1
  2. (
  3. number1  decimal(5,1),
  4. number2  decimal(5,1)
  5. )
  6.  
  7. DECLARE @count1 decimal(4,1)
  8. DECLARE @count2 decimal(4,1)
  9. DECLARE @count3 decimal(4,1)
  10. DECLARE @count4 decimal(4,1)
  11. DECLARE @count5 decimal(4,1)
  12. DECLARE @count6 decimal(4,1)
  13. set @count1 =6
  14. set @count2 =4
  15. set @count3 =10
  16. set @count4 =4
  17. set @count5 =0
  18. set @count6 =0
  19.  
  20. select @count4=(@count1/@count2) from test1
  21. select @count6=(@count1/@count2) from test1
  22. print @count4
  23. print @count6
  24.  
  25.  
  26. insert into test1 values('@count5','@count6')
Any help is appreciate.
Jul 17 '14 #1
1 3377
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

Remove the quotes around your variable names. It's trying to insert the string '@count5' and not the value stored in @count5.
Jul 17 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Terri | last post by:
I'd I have a problem I'd like to post CREATE TABLE and INSERT statements that will create my table and insert data into the table. I can use the scripting feature in Enterprise Manager to...
1
by: Michael Hardy | last post by:
I would like to reopen this discussion. I need to create this table using SQL that will return this dataset. BRAID RATEDEFID MIN(BRADATE) MAX(BRADATE RATECODE PRODNAME 614 14 12/1/2002...
0
by: Praveen_db2 | last post by:
Hi All Db2 8.1.3 I have a SP ,Say SP1. SP1 is returning a dynamic result set i.e. a cursor is left opened. This SP is called in another SP ,Say SP2. A result set locator (RS1) is associated...
5
by: salex | last post by:
Hi, I don't know if I'm posting this question in the right forum. I'm new to SQL, and I'm hoping to get some help in selecting a value based on a hierachy. What I'm trying to achieve is...
14
by: Ben | last post by:
I don't know whether anyone can help, but I have an odd problem. I have a PSP (Spyce) script that makes many calls to populate a database. They all work without any problem except for one...
2
by: pattie | last post by:
I hava been trying to add data into a table using INSERT into unsuccessfully.Doing it manually works,and all other constructs works like SELECT,UPDATE.So what might be a cause. My syntax ...
7
by: bhargavigupta | last post by:
hi, In my application i have one checkbox when ever i am entering values to the page it has to store the values into the database table using insert statement , remaining values r...
0
by: bimeldip | last post by:
Hi, I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be...
7
by: jthep | last post by:
Hi, I'm a newbie at this but how can I populate a table with data from other tables by using INSERT statements? Below is of what I have so far, I have to populate the PERSON_PROFILE table. I've...
4
by: kisho | last post by:
i have created on table Customer which have column as primary key and IDENTITY(10000000,1). What i want is how can i insert values for the table using INSERT INTO Customers values(<values>) query...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.