Multiple Like Output in SQL

Posted by Gg under Sql Server on 7/9/2012 | Points: 10 | Views : 989 | Status : [Member] | Replies : 4
Hi,

I have a doubt in SQL

I have ten records in a table and i want to display that records based on
my criteria.

Select * from Tablename
where (Column like 'D%' or Column like 'B%' or Column like 'A%' or Column like 'C%' or Column like 'E%' )


myoutput

AA
BB
CC
DD
EE

Expected Output
DD
BB
AA
CC
EE

Can you please help on to get my expected output.

Thanks,
gg




Responses

Posted by: Premalatha on: 7/9/2012 [Member] Starter | Points: 25

Up
0
Down
http://blog.sqlauthority.com/2007/06/11/sql-server-cannot-resolve-collation-conflict-for-equal-to-operation/

Premalatha
Software Engineer

Gg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pandians on: 7/10/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
@Premalatha, COLLATION is different! (To forcing sensitivity of data like Case, Accent, width,...)

I think we don't have direct way...! But, we can do with some work around!

I assume, You searching in same column
Create Table #Creiteria

(
Seq Int IDENTITY(1,1),
Creiteria Varchar(10)
)
Go
Insert #Creiteria Values('D')
Insert #Creiteria Values('B')
Insert #Creiteria Values('A')
Insert #Creiteria Values('C')
Insert #Creiteria Values('E')
Go
Select A.* from Table1 A, #Creiteria H
Where A.Column1 Like H.Creiteria + '%'
Order by H.Seq
Go
Drop Table #Creiteria




Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Gg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 7/10/2012 [Member] Starter | Points: 25

Up
0
Down
hI

Pandians

Nice Way its Working correctly
Thanks


R D Patel

Gg, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 7/11/2012 [Member] Starter | Points: 25

Up
0
Down
Hi
Gg

Did you get the sollution or not?


R D Patel

Gg, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response