Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Implicit conversion varchar to money not allowed?

Status
Not open for further replies.

Spork52

Programmer
Nov 20, 2007
134
US
Documentation for T-SQL says that the conversion from varchar to money is implicit ( see chart about 1/3 down the page).

But, when I try inserting into a money column like this:

Code:
sql = "INSERT INTO myTable (myMoney) VALUES ('" &  replace(somemoney, "'","''") & "')"
(where somemoney is a string. e.g., 38.25)

I get this error:

Disallowed implicit conversion from data type varchar to data type money, table 'myTable', column 'myMoney'. Use the CONVERT function to run this query.

But this works:

Code:
sql = "INSERT INTO myTable (myMoney) VALUES (" &  replace(somemoney, "'","''") & ")"


Is the documentation wrong or is my understanding wrong? Or, is the conversion implicit only in certain circumstances?
 
It' s not, the intersection cell falls on the diagonal and it' s empty. Sorry.

MCP SQL Server 2000, MCTS SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)
 
Ah, sorry, I take that back. It is implicit.

MCP SQL Server 2000, MCTS SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top