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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-07-22 : 07:58:41
|
| Trina writes "SQL Server 7.0 SP 3I have data that has an asterisk as the first letter in some cases indicating that training is required for this document. I need to search for documents that begin with a specific letter. how do I: select only those records where first letter matches my search criteria (which would be the second letter for those record that have an asterisk as the first letter!)SELECT sortdesc = CASE CHARINDEX('*',cms.docdesc,0) WHEN 1 THEN SUBSTRING(cms.docdesc,2,500) ELSE cms.docdesc ENDFROM cmsdoc cmsWHERE UPPER(LEFT(sortdesc,1)) = 'A' This returns an error on this stating that sortdesc is an invalid column name" |
|
|
Nazim
A custom title
1408 Posts |
Posted - 2002-07-22 : 08:26:46
|
| SELECT sortdesc = CASE CHARINDEX('*',cms.docdesc,0) WHEN 1 THEN SUBSTRING(cms.docdesc,2,500) ELSE cms.docdesc END FROM cmsdoc cms WHERE CASE CHARINDEX('*',cms.docdesc,0) WHEN 1 THEN UPPER(LEFT(sortdesc,1)) = 'A' ELSE cms.docdesc END -------------------------What lies behind you and what lies ahead of you are small matters compared to what lies within you.-Ralph Waldo Emerson |
 |
|
|
|
|
|