Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 1st, 2004, 12:19 AM
SQ SQ is offline
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data types in SQL

Can you help? I'm trying to insert data into a table. When I try to enter values into the money data column, i get the message 'disallowed implicit conversion from data type varchar to data type money, use the convert function to run this query'

What do i need to do?

 
Old October 1st, 2004, 08:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you post on how you are trying to insert values into that column? May be you can post the query here, that you use to do that.

But I assume that you are using Quotes around the value that you try to insert into money data column, from the error you say. You should avoid using quotes in case you use any.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 1st, 2004, 09:11 PM
SQ SQ is offline
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply happygv. I am trying to teach myself SQL 2000 and I am just a beginner so your help is really appreciated. What I have tried to enter into a table that has as its dictionary Prod ID-integer (PK),ProdName varchar, Co_ID integer(FK),Capitalisation money.
This is the method I have used
INSERT INTO Products
VALUES ('real estate','543','$575,000.00');
that's when I got the message previosly listed- I won't have access to the table till next wednesday but I will try again removing the quotes from the money value if you think that will help.

 
Old October 2nd, 2004, 05:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi SQ,

My assumption was right in your case.
Code:
INSERT INTO Products
VALUES ('real estate','543','$575,000.00');
Change that to
Code:
INSERT INTO Products
VALUES ('real estate',543,$575000.00);
Also don't use quotes around 543, as ProdId seems to be an integer.

If that returned error, you should sequence the values in the order of columns that are defined in the table structure.

Here is the other way of using this.
Code:
INSERT INTO Products(ProdName, ProdId, Capitalisation)
VALUES ('real estate',543,$575000.00);
If space used within the COLUMNNAME like "Prod ID", use that within []s, but it is a good practice to avoid white space/hyphen usage in COLUMNNAMEs.

Try this in your query analyser.
Code:
exec sp_datatype_info
go
and look for values under LITERAL_SUFFIX and LITERAL_PREFIX columns against "money" value under TYPE_NAME. This would let you know what should be used as prefix and suffix for any datatype, when values are supplied in a query.

Hope that explains.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 3rd, 2004, 02:07 AM
SQ SQ is offline
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Vijay, You can't imagine how good it is to find someone who can give you answers.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Types Clive Astley Access 1 January 17th, 2006 04:13 PM
Data Types edward2006 Infopath 0 November 7th, 2005 06:06 PM
SQL Server data types spinout SQL Server 2000 5 September 23rd, 2004 02:27 AM
Data Types bph Access VBA 3 January 25th, 2004 05:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.