Jump to content

Sorting based on alphabets...


pulpfiction

Recommended Posts

I have a list of company names, [this list has like 650 names] So to make the search easy, the top of the list has alphabets A to Z and "ALL" and when you click the alphabet then only those names starting with that alphabet show up in the list [i dont know if there's any tech name for this...] I use a stored procedure to do this. This is how its done for alphabetsALTER PROCEDURE SP_Name(@alpha varchar(1))ASSELECT fldnamesFROM tblnameWHERE listfldname LIKE @alpha+'%'RETURNQuestion: There are few names which start with numbers, how can i get those alone. Hope i am clear....TIA

Link to comment
Share on other sites

Yeah I missed this point,For alphabets i have all of them seperate likeA B C D .... Z but the list of names that start with number is less, so i dont wanna do somthing like 0 1 2 3 ..... 9, instead like this(ALL) (0-9) (A) ..... (Z) Now (0-9) is a single button and when someone clicks on it all the names starting with number must be listed? How can we do this??

Link to comment
Share on other sites

you could setup a seperate SP like so

SELECT fldnamesFROM tblnameWHERE listfldname LIKE '0%'OR listfldname LIKE '1%'OR listfldname LIKE '2%'OR listfldname LIKE '3%'OR listfldname LIKE '4%'OR listfldname LIKE '5%'OR listfldname LIKE '6%'OR listfldname LIKE '7%'OR listfldname LIKE '8%'OR listfldname LIKE '9%'

or pass in 'all' to @alpha in your existing SP and use a IF ELSE to determine which to use.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...