what is wrong with this statement?

  • Hi,

       can somebody tell me please what is wrong with this statement

     

    INSERT INTO TransactionCountstest (Month_of_file, CalcAction, TableValue, CalculatedValue)

          SELECT @Month_of_file_filter AS Month_of_file ,'14' AS ID  ,CONVERT(varchar(7), Date_From, 120) as TableValue, SUM(Amount) as CalculatedValue 

          FROM GE_Transaction

          WHERE Month_of_file = @Month_of_file_filter

          GROUP BY CONVERT(varchar(7), Date_From, 120)

  • I'm assuming you are getting an truncate error.

     

    Have you tried using varchar(10) instead of varchar(7)?

  • i guess that is not the solution because see when i do the insert in the table Transactioncountss it is getting some weird dates and inserting in the TransactionCountss instead from the  Date_from column

  • Could you please read this article.  It'll show you the best possible way to ask a question in forums like this one.  That will also let us give you the correct answer on the first try, every time.

    I'll check back when you have reformulated the question.

  • My question is how can i correct the problem with my date issue, when i run the proc I want it to get the date from the column "Date_From" in the

    Table GE_Transaction and insert in the TransactionCountss Table.

     

     

    Thanks for the help

  • Sorry I forgot to post the link I wanted you to read .

    http://www.aspfaq.com/etiquette.asp?id=5006

  • Remi's solution and diagnosis was dead on. Please re-read it.

    >>i guess that is not the solution because see when i do the insert in the table Transactioncountss it is getting some weird dates

    "Weird Dates", huh ?

    What does this return when you run it with today's date ?

    Select convert(varchar(7), getDate(), 120)

    Looks like a "weird date" to me. String truncation, just like Remi pointed out.

    This thread should have been over at reply #1.

     

Viewing 7 posts - 1 through 6 (of 6 total)

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