Monday, February 27, 2012

convert more then value to comma separte value in sql server

 DECLARE @choices varchar(5000) 
 set @choices = '' 
 select @choices = @choices + (cp.DefaultCaption + ', ' ) from test qc  left outer join test1c on  qc.ChoiceID = c.ChoiceID left outer join test2 cp on cp.CaptionID = c.CaptionID              
 where qc.QuestionnaireID  in(@questionnaireId )
 if(len(@choices)>0) 
 BEGIN 
    set @choices = substring(@choices, 0 ,len(@choices)) 
 END 
print @choices

No comments:

Post a Comment