Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | Swati JainPosting Yak  Master
 
 
                                        139 Posts | 
                                            
                                            |  Posted - 2007-10-22 : 03:04:45 
 |  
                                            | SELECT @Output =  CASE @Output 	WHEN '' THEN  ReceiptsDetail.DocumentNumber 				WHEN 'Blank' THEN  @Output+''                 ELSE @Output + ', ' + ReceiptsDetail.DocumentNumber		ENDActualy in the text marked in red I want that if ReceiptsDetail.DocumentNumber ='Blank' then it should be excluded from @Output but how here I can write this condition |  |  
                                    | rksingh024Yak Posting Veteran
 
 
                                    56 Posts | 
                                        
                                          |  Posted - 2007-10-22 : 03:18:10 
 |  
                                          | It seems you want two case condition. If yes, then you can use case within case. Or you can use something like thisselect @output = case when @output='' and ReceiptsDetail.DocumentNumber ='Blank' then ...else ... endRamesh Singh |  
                                          |  |  |  
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2007-10-22 : 04:15:02 
 |  
                                          | or SELECT @Output = @Output+ 	CASE @Output ='' and ReceiptsDetail.DocumentNumber ='Blank' THEN '' 		ELSE  ', ' + cast(ReceiptsDetail.DocumentNumber as varchar(20)) 	ENDMadhivananFailing to plan is Planning to fail |  
                                          |  |  |  
                                    | ChandanJStarting Member
 
 
                                    6 Posts | 
                                        
                                          |  Posted - 2007-10-29 : 14:00:27 
 |  
                                          | try thisSELECT @Output = @Output + CASE WHEN ReceiptsDetail.DocumentNumber = 'Blank' THEN ''     ELSE ReceiptsDetail.DocumentNumberEND |  
                                          |  |  |  
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2007-10-30 : 01:54:08 
 |  
                                          | quote:You need to convert the documentnumber to varchar if it is of INT datatypeMadhivananFailing to plan is Planning to failOriginally posted by ChandanJ
 try thisSELECT @Output = @Output + CASE WHEN ReceiptsDetail.DocumentNumber = 'Blank' THEN ''     ELSE ReceiptsDetail.DocumentNumberEND
 
 |  
                                          |  |  |  
                                |  |  |  |