Problems inserting monetary data from stored procedure

  • Hello,

    I have a stored procedure that I just migrated to SQL 2005 from SQL 7. It

    has worked in previous verions of SQL, but does not work now.

    I have something like:

    insert into TableA (Account,OutstandingLedger

    select Account,OutstandingLedger=$0.0 from TableB

    where ...

    Account is varchar and OutstandingLedger is money. For some reason in SQL

    2005, this puts NULL in OutstandingLedger in TableA, where in previous

    version of SQL server it would put 0.00.

    If I directly execute the following:

    insert into TableA (Account,OutstandingLedger VALUES ('abc',$0.0)

    then OutstandingLedger has the value of 0.00.

    What am I missing here?

    thanks in advance for any advise.

    --mitch

  • insert into TableA (Account,OutstandingLedger

    select Account,OutstandingLedger=$0.0 from TableB

    don't do an assign operation in the select;

    simply SELECT Account,0.00 from TableB

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply