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  | 
                             
                            
                                    | 
                                         scottdg 
                                        Starting Member 
                                         
                                        
                                        20 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2011-12-16 : 14:59:32
                                            
  | 
                                             
                                            
                                            | I apologize in advance if this is the wrong place for this question and ask a mod to move it to the appropriate forum.We recently merged with another company and a former employee wrote some of their website including a function that will check a product code in the database to see if a "W" is anywhere in the code. The problem is it should only be checking the first position. We have other codes that have a "W" elsewhere to indicate a meeting in the western part of the state. Anyone know how to modify the following so it will only check the first letter of the product code?if instr(ucase(rs("PRODUCT_CODE")), "W") > 0 then 	TYPEOFPROGRAM = "WEBINAR" | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     james_wells 
                                    Yak Posting Veteran 
                                     
                                    
                                    55 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-11-29 : 10:28:26
                                          
  | 
                                         
                                        
                                          | where upper(substring(PRODUCT_CODE,1,1)) = 'W'  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     nigelrivett 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    3385 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-11-29 : 10:39:41
                                          
  | 
                                         
                                        
                                          | if ucase(left(rs("PRODUCT_CODE"),1)) = "W"But you should consider moving this code into a stored procedureso that the database can be restructured if needed.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |