Click here to Skip to main content
15,885,925 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
means the name starts and ends wiith the same charecter
please help me
examples are:
asha
amma
bob
dad
pop
rear
Posted

u can try something like this...
SQL
Create Table #Temp
        (
         Name Nvarchar(40) Collate SQL_Latin1_General_CP1_CS_AS
        )

Insert into #Temp
Values('asha'),('amma'),('bob'),('dad'),('Rear'),('Removed')

Select * From #Temp   
Where Left(Name,1) =SubString(Name,Len(Name),1)  -- Case Sensitive

Select * From #Temp
Where Lower(Left(Name,1)) =Lower(SubString(Name,Len(Name),1)) -- Case InSensitive

Drop Table #Temp

Output:
SQL
Name
------
asha
amma
bob
dad

SQL
Name
----
asha
amma
bob
dad
Rear
 
Share this answer
 
v2
Comments
Amol_B 28-Oct-13 8:21am    
Nice one
Raja Sekhar S 29-Oct-13 0:16am    
Thank you... Amol_B
Google gave me this link when used keywords "SQL query palindrome"
SQL SERVER – Check If String is a Palindrome in Using T-SQL Script – Reverse Function[^]

EDIT
-----------------
You could customize this based on your requirement.
 
Share this answer
 
v2
SQL
Select * From #Temp
Where Lower( left(Name,1)) =Lower(right(Name,1)) -- Case InSensitive



Just use right function instead of substring function for simplicity and little bit consistency (left & right function)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900