SQL Server Need to Handle NULL values inside Stuff function -


my required output should thisi have concatenate subavlues of multivalued record separator , if middle subvalue null have concatenate separator. have written following code.

select b.account_number ,b.co_code,(select case when other_officer not null ,  0 < (select count(c.account_number) efz_account_details c c.account_number = a.account_number , c.other_officer null ) isnull(b.other_officer +']',']') else null end efz_account_details     a.account_number = b.account_number     xml path(''))as acc_deb_limit efz_account_details b group account_number,co_code 

this working, though subvalues of multivalued record null concatenating separator , output coming this

i display null incase subvalues null , need remove separator @ ending of string. please me in regard. in advance

i tried logic also, giving me same result

select account_number ,co_code, stuff(( select  isnull(']'+ other_officer,']') efz_account_details b.account_number = a.account_number xml path('')),1 ,1, '')  alt_account_type efz_account_details b group account_number,co_code; 

i'm not sure if understood requirements, query solved problem.

select   case   when d null , c not null     isnull(a,'')+']'+isnull(b,'')+']'+ c  when d null , c null , b not null      isnull(a,'')+']'+ b  when d null , c null , b null , not null      when d null , c null , b null , null      null  else    isnull(a,'')+']'+isnull(']'+b,'')+']'+isnull(']'+c,'')+']'+isnull(d,'')+']' 

end testtable;

see sql fiddle


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -