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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-02-25 : 09:02:05
Lady writes "could anyone tell me how shell I make following query:
I have table T1
with column C1 nvarchar(100)
I have to get full value C1
if lEN(C1)<10
AND LEFT(C1,10) +'...' if C1 more then 20 symbols.
the query like this

for example:
C1
test
whery long...
my test
it's again..."

nr
SQLTeam MVY

12543 Posts

Posted - 2002-02-25 : 09:07:20
What if it's between 10 and 20?

select
case
when len(C1)<=10 then C1
when len(C1) > 20 then left(C1,10) + '...'
end
from tbl

if the second bit should have been 10 then you can

select left(C1,10) + case when len(C1) > 10 then '...' else '' end
from tbl


==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -