| Author | Topic | 
                            
                                    | anabelleStarting Member
 
 
                                        19 Posts | 
                                            
                                            |  Posted - 2010-02-01 : 03:56:13 
 |  
                                            | I would like to do a query that will read first two characters on the Name Column withour specifying a character, it will just automatically display all the results of all first two characters. Ex.on Name ColumnDexterMarieJosephRESULT should beDeMaJo |  | 
       
                            
                       
                          
                            
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2010-02-01 : 04:03:48 
 |  
                                          | [code]SELECT Name,LEFT(Name,2) AS Result FROM Table[/code]make sure you post this in t-sql forums in future.This is script library intended to post working scripts |  
                                          |  |  | 
                            
                       
                          
                            
                                    | anabelleStarting Member
 
 
                                    19 Posts | 
                                        
                                          |  Posted - 2010-02-01 : 04:10:21 
 |  
                                          | Ahmm...sori.thank you... |  
                                          |  |  | 
                            
                       
                          
                            
                                    | anabelleStarting Member
 
 
                                    19 Posts | 
                                        
                                          |  Posted - 2010-02-01 : 04:22:37 
 |  
                                          | It gives me a null result for names to appear, all the names encoded datatype was varchar, when i run that script it gives me a null a value.I tried to run that script again into another table that contains both number and character, instead of giving me the first two characters it gives me the total counted first two character in that column. Is there any other way to do it? to give me a result as mentione earlier?please... |  
                                          |  |  | 
                            
                       
                          
                            
                                    | khtanIn (Som, Ni, Yak)
 
 
                                    17689 Posts | 
                                        
                                          |  Posted - 2010-02-01 : 04:44:12 
 |  
                                          | if it gives null, it means for those records the value for column [Name] is NULL.I don't quite understand the situation you have in another table. Can you post some sample data and the result ? KH[spoiler]Time is always against us[/spoiler]
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2010-02-01 : 06:11:17 
 |  
                                          | quote:when it gives you null? what were contents of name column then?ok, in such cases how will be format, will it be numbers and characters mixed?Originally posted by anabelle
 It gives me a null result for names to appear, all the names encoded datatype was varchar, when i run that script it gives me a null a value.I tried to run that script again into another table that contains both number and character, instead of giving me the first two characters it gives me the total counted first two character in that column. Is there any other way to do it? to give me a result as mentione earlier?please...
 
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | anabelleStarting Member
 
 
                                    19 Posts | 
                                        
                                          |  Posted - 2010-02-02 : 04:40:29 
 |  
                                          | i have executed the script on the Name Table that contain data examples:Andrea SolisReynaldo RochMyrna Tehand this is the script i run the one u gaveSELECT Name,LEFT(Name,2) AS Result FROM DataNameand the result wasNAME    RESULT(nothing show up)Why it so?its purely text.... |  
                                          |  |  | 
                            
                       
                          
                            
                                    | senthil_nagoreMaster Smack Fu Yak Hacker
 
 
                                    1007 Posts | 
                                        
                                          |  Posted - 2010-02-02 : 04:44:51 
 |  
                                          | Is the data having spaces in leftmost???if yes SELECT Name,LEFT(ltrim(Name),2) AS Result FROM DataNameSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |  
                                          |  |  | 
                            
                       
                          
                            
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2010-02-02 : 04:46:02 
 |  
                                          | Did you get results for this?SELECT Name FROM DataNameMadhivananFailing to plan is Planning to fail |  
                                          |  |  | 
                            
                       
                          
                            
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2010-02-02 : 05:06:48 
 |  
                                          | quote:are you sure you got nothing for name field also?Originally posted by anabelle
 i have executed the script on the Name Table that contain data examples:Andrea SolisReynaldo RochMyrna Tehand this is the script i run the one u gaveSELECT Name,LEFT(Name,2) AS Result FROM DataNameand the result wasNAME    RESULT(nothing show up)Why it so?its purely text....
 
 |  
                                          |  |  | 
                            
                            
                                |  |