Format Message

  • Hi, I guess I am missing something but this format message script doesn't work.

    SELECT    FORMATMESSAGE('CTL|%s|%s|%s|', FORMAT(CURRENT_TIMESTAMP, 'yyyyMMdd'),CAST(SUM(totamount) AS varchar(MAX),'100'))
    FROM     table.xxxx

    If I leave the '100' out it returns null, when i put it back i get syntax error so what is wrong?

    Thanks

  • Parenthesis were not properly managed, corrected below
    SELECT  FORMATMESSAGE('CTL|%s|%s|%s|', FORMAT(CURRENT_TIMESTAMP, 'yyyyMMdd'),CAST(SUM(totamount) AS varchar(MAX)),'100')
    FROM  table.xxxx

    '%s' --> signifies as dynamic message
    since there are 3 of it so 3 parameters are required i.e., in above case [date], sum of totamount and value '100'
    If you do not want 100 then remove the one of the '%s'

  • I do want the 100, but it doesn't work it gets syntax error?

  • have you tried above solution, it works for me

Viewing 4 posts - 1 through 3 (of 3 total)

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