Expression not working in MS SQL server

63 views Asked by At

Below is the expression it is used to concatenate but for some reason the result is giving just first two letter of each string. I'm little confuse what's wrong with it. Below expression is working fine in sybase but not in sql server.Thank you Example:

F
G
Required Output:
For Young Musicians Program
GV- Record Sheet.
IF(ISNULL(fd_m_an_report),'', fd_m_an_report )  +  
IF((NOT ISNULL(fd_m_an_report)) AND (NOT ISNULL(fd_m_comment)), '~r~n~r~n', '') + 
IF(ISNULL(fd_m_comment ),'',  fd_m_comment)
1

There are 1 answers

0
Brian Pressler On

This looks like you are using Excel functions. To get something similar in SQL Server syntax you need:

select 
    ISNULL(fd_m_an_report,'')  +  
    case when fd_m_an_report + fd_m_comment is null then '' else '~r~n~r~n' end + 
    ISNULL(fd_m_comment,'')
from MyTable