Wayne Barron
asked on
SQL Server Return the letters of the alphabet for the names in the table column.
Hello, All;
For SQL Server 2016.
I used to have this code lying around somewhere, but I am unable to find it.
OK.
table (SomeNames)
Johnny
Carr
Wayne
Ronda
Valerie
Tanya
Joey
Vin
Ron
Tony
OK, in the above, I would like to have a list of the Alphabets
Since there is NOT the whole list of letters to comprise the entire Alphabet, it would only show the letters for the names that are available.
For the example above, would be.
C
J
R
T
V
W
Once there are more names added which contain the other letters in the alphabet, then it will then display them letters.
And what I am going to do, is have each letter as a hyperlink on the page, to display all the names for that letter.
Hope this is clear.
I wish I knew where the code was at that I once have.
It is probably buried in a project script, of which I do not remember the name I gave it.
As it was about 5+ years ago, that I remember using it last, as it was at my old home.
Thanks all;
Wayne
For SQL Server 2016.
I used to have this code lying around somewhere, but I am unable to find it.
OK.
table (SomeNames)
Johnny
Carr
Wayne
Ronda
Valerie
Tanya
Joey
Vin
Ron
Tony
OK, in the above, I would like to have a list of the Alphabets
Since there is NOT the whole list of letters to comprise the entire Alphabet, it would only show the letters for the names that are available.
For the example above, would be.
C
J
R
T
V
W
Once there are more names added which contain the other letters in the alphabet, then it will then display them letters.
And what I am going to do, is have each letter as a hyperlink on the page, to display all the names for that letter.
Hope this is clear.
I wish I knew where the code was at that I once have.
It is probably buried in a project script, of which I do not remember the name I gave it.
As it was about 5+ years ago, that I remember using it last, as it was at my old home.
Thanks all;
Wayne
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Coool, glad that it helps
far prefer the KISS principle :
select distinct left(columnnames,1) as Letters
from yourtable
order by 1
select distinct left(columnnames,1) as Letters
from yourtable
order by 1
ASKER
This is what I ended up using.
Open in new window