Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 1st, 2004, 12:19 AM
SQ SQ is offline
Registered User
 
Join Date: Sep 2004
Location: Rockdale, NSW, Australia.
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?

Reply With Quote
  #2 (permalink)  
Old October 1st, 2004, 08:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
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
Reply With Quote
  #3 (permalink)  
Old October 1st, 2004, 09:11 PM
SQ SQ is offline
Registered User
 
Join Date: Sep 2004
Location: Rockdale, NSW, Australia.
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.

Reply With Quote
  #4 (permalink)  
Old October 2nd, 2004, 05:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
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
Reply With Quote
  #5 (permalink)  
Old October 3rd, 2004, 02:07 AM
SQ SQ is offline
Registered User
 
Join Date: Sep 2004
Location: Rockdale, NSW, Australia.
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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:37 AM.


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