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  | 
                             
                            
                                    | 
                                         magmo 
                                        Aged Yak Warrior 
                                         
                                        
                                        558 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2014-12-11 : 03:38:23
                                            
  | 
                                             
                                            
                                            | HiI have a stored procedure thattake the following parameter..@GenderID nVarChar(500I need to check if that value is '' and if so set it to '0'. How can I do that? | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     James K 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    3873 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2014-12-11 : 08:19:57
                                          
  | 
                                         
                                        
                                          | [code]SET @GenderID = CASE WHEN @GenderID = '' THEN '0' ELSE @GenderID END;[/code]You might also want to set it to something if it is null. A similar check can do that, or more compactly[code]SET @GenderID = COALESCE(NULLIF(@GenderID,''),'0')[/code]  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     magmo 
                                    Aged Yak Warrior 
                                     
                                    
                                    558 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2014-12-11 : 09:51:58
                                          
  | 
                                         
                                        
                                          | Thanks a lot!  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |