Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Apples
Posting Yak Master
146 Posts |
Posted - 2008-03-24 : 13:57:34
|
| I have a table of definitions:---------------------------Glossary---------------------------Term | Definition---------------------------What I need to do is find all the letters that are at the beginning of the terms.So if I have "apple" as a term, A is returned.Also, if I have "forest", "fruit", and "flower", F is returned, but only once.And if I have no terms that start with Q, Q is not returned.Lastly, if I have a term like " 'Walking' Pneumonia", it should recognize that the term starts with a W. |
|
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-03-24 : 13:59:37
|
| select distinct left(term,1) from Glossary order by 1"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-03-24 : 14:00:39
|
| or SUBSTRING(term,1,1) |
 |
|
|
Apples
Posting Yak Master
146 Posts |
Posted - 2008-03-24 : 14:01:26
|
| Will that be able to handle the last problem though?If I have a term that starts with a quotation rather than a letter, will it grab the first letter? |
 |
|
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-03-24 : 14:03:23
|
| No but this will declare @Glossary table ( term varchar(100), def varchar(100))insert into @Glossary (term)select 'apple' union select 'bananna' union select 'Walking Pneumonia' union select '''walking'''select * from @Glossary select distinct left(replace(replace(ltrim(term), '''', ''), '"', ''),1) from @Glossary order by 1"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
|
|
|
|
|
|