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 |
|
frank.svs
Constraint Violating Yak Guru
368 Posts |
Posted - 2007-02-21 : 01:23:40
|
| Dear pals, I have a table as followscreate table mst_org( org_id numeric(18,0), org_name varchar(20), org_desc varchar(2000))insert into mst_org values(1,'Oracle','Oracle supply a range of software to manage, share and protect data and information.')insert into mst_org values(2,'SQL Server','Visit this portal for all the latest news and articles to help you evaluate Microsoft SQL Server 2005 for your data management and analysis needs')insert into mst_org values(3,'Sybase','Sybase Corp')I need to display the output as follows. i.e suppose if my org_desc column value length greater than 30 then is should display three ... in the output as follows.I have tried this using cursor i.e i processes row by row and displayed as follows. But is there a way which can be done using a single SELECT stmt with CASE stmt.select * from mst_org1 Oracle Oracle supply a range of so...2 SQL Server Visit this portal for all t...3 Sybase Sybase CorpAny Suggestions is appreciated.Regards,franky |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-02-21 : 01:27:37
|
| [code]Select org_id org_name, Case When Len(Org_Desc)>30 Then Left(Org_Desc, 27) + '...' Else Org_Desc End as Org_DescFrom mst_org[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-21 : 01:27:46
|
[code]select org_id, org_name, case when len(org_desc) > 30 then left(org_desc, 27) + '...' else org_desc endfrom mst_org[/code] KH |
 |
|
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2007-02-21 : 01:30:50
|
| why are u trying this at backend? you can do it in front end, using grid like controls. coz, if u will run this query, u will not get remaining part of data, but in grid u can expand the column, so that it will give u the same effect.let us know if u r trying something elsethanks,Mahesh |
 |
|
|
frank.svs
Constraint Violating Yak Guru
368 Posts |
Posted - 2007-02-22 : 07:53:17
|
| Thanks for the help. |
 |
|
|
|
|
|
|
|