Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    18

    Unanswered: Varchar to Money Error

    I perform a select statement, and when I put the value into @Number_of_Transactions it is a varchar(50).
    Since it is going into a new table with a Money datatype, I convert it, but I am getting two errors, one saying:
    Server: Msg 257, Level 16, State 3, Procedure createspend, Line 29
    Implicit conversion from data type money to varchar is not allowed. Use the CONVERT function to run this query.

    and the other saying:
    Server: Msg 260, Level 16, State 1, Procedure createspend, Line 31
    Disallowed implicit conversion from data type varchar to data type money, table 'ITPSG.dbo.CCSPENDREPORTTEST', column 'TOTAL'. Use the CONVERT function to run this query.


    Below is the code...what am I missing?
    FETCH NEXT FROM cursor2
    INTO @NAME, @AWID, @Total_Amount, @Number_of_Transactions, @Industry, @Costctr

    Set @Company = Left(@Costctr, 4)
    Set @Office = SUBSTRING(@Costctr, 5, 3)
    Set @CC = Right(@Costctr, 3)
    29- Set @Total_Amount = Convert(Money, @Total_Amount)
    Print 'inserting'
    31- Insert into CCSPENDREPORTTEST (VP, VPAWID, EMPLOYEE, AWID, COMPANY, OFFICE, COSTCENTER, TRANSACTIONS, CATEGORY, TOTAL, STATUS) values (@VPNAME, @VPAWID, @NAME, @AWID, @Company, @Office, @CC, @Number_of_Transactions, @Industry, @Total_Amount, 'MATCHED')
    -Doug Picanzi

  2. #2
    Join Date
    Jan 2003
    Location
    India
    Posts
    523
    Set @Company = Left(@Costctr, 4)
    Set @Office = SUBSTRING(@Costctr, 5, 3)
    Set @CC = Right(@Costctr, 3)

    Print 'inserting'
    31- Insert into CCSPENDREPORTTEST (VP, VPAWID, EMPLOYEE, AWID, COMPANY, OFFICE, COSTCENTER, TRANSACTIONS, CATEGORY, TOTAL, STATUS) values (@VPNAME, @VPAWID, @NAME, @AWID, @Company, @Office, @CC, @Number_of_Transactions, @Industry,
    convert(money,@Total_Amount), , 'MATCHED')



    don't assign the money value to a varchar instead convert it in the insert statement
    Last edited by harshal_in; 09-24-03 at 03:34.

  3. #3
    Join Date
    Aug 2003
    Posts
    18

    Worked

    Thanks!
    -Doug Picanzi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •