sql server 2005 - Reducing text in a text field -


i'm working on view selects large text field table. (no, not snapshots.) table contains errorlog web application provides access it. however, errorlog contains long texts cause column extremely wide.
want select text field, any word longer 20 characters must replaced first three, ellipse (...) , last 3 letters. example:

 - system.web.httpexception: client    disconnected. --->    system.web.ui.viewstateexception:    invalid viewstate. client ip:    xxx.xxx.xxx.xxx port: xxxx    user-agent: mozilla/4.0 (compatible;    msie 7.0; windows nt 6.1; wow64;    trident/4.0; slcc2; .net clr    2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; infopath.3; .net4.0c;    .net4.0e) viewstate:    t89rigytoaletokughad85kzodro/ut3vlnd1qecsyf1t9ggnildrvbrn8l45svx8aszrs6zyengk8mkdporeci4j0x5ismi0deldf4nlknlloe4xaoomulj7htfrxavqyofsvzsvyhwpwclug26rjt4ybgr1ijygqwx9kvplidasdur0annmvd9fva8fi33ny7fuijxpkmpqkbykyjtagzu4piji88mmqwqdmnzmbxm965+bn+rsvtsxrgwzllhzfcrk0leccrzerqyncmmhupgm9yb1+uaprfeca3r4vcacn6vv/unzekbxp5rzavdgjb9rggxkhhdbveccd3h2n6x5rxkkldy76h3avz8h8dfjpdjvre8exndkhecozwz0ejyx9hnme2kz2+gmeqafi/mnj5nzzcjocfysdbwaorpegbznqx9gbjds32e8admgdk+zvxl3mt4pf3e6zth45n1ccjbnclya6rd9d9mfipm6dfbxubixw8dbzmt/6vecw0ypfrcjkcod3d7+kva44ruiikkiiqr0vplllja/ggh/4ihq9sqgopwgjuohgfy++5g14biv3zyzm8vj+re3imfbwzcui4scefy7l7i6nrl27pd+6qz60wamv6lpl3y88j5cuivaizqinsot5htistf00+d0pfptx5wwlmprzm1dvfxcl/0x3bpvlndof5aw+pjxap19shr+puuaem9yo0zmhgg+l5+dn2kuhspqfpwc6fxczvdicxlr8+x4juy2+fxeblabla 

this must become:

 - system.web.httpexception: client    disconnected. --->    system.web.ui.viewstateexception:    invalid viewstate. client ip:    xxx.xxx.xxx.xxx port: xxxx    user-agent: mozilla/4.0 (compatible;    msie 7.0; windows nt 6.1; wow64;    trident/4.0; slcc2; .net clr    2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; infopath.3; .net4.0c;    .net4.0e) viewstate: t89...bla 

and yes, first text extremely wide... has trouble displaying correctly. :-)
so, need regular expressions or whatever. thus: select regex(something, something, something) mytable; or whatever.
is possible?

maybe help

create function dbo.ellipsetextwords(@text varchar(max), @ellipsedsize int, @separator varchar(1), @ellipsislength int = 3) returns varchar(max) begin      declare @tokens table     (         token varchar(max)     )      while (charindex(@separator, @text) > 0)     begin         insert @tokens         select ltrim(rtrim(substring(@text, 1, charindex(@separator, @text) - 1)))          set @text = substring(@text, charindex(@separator, @text) + 1, len(@text))     end      insert @tokens     select ltrim(rtrim(@text))      update @tokens set token = left(token, @ellipsislength) + '...' + right(token, @ellipsislength) token <> '' , len(token) > len(left(token, @ellipsedsize))      declare @ellipsed varchar(max)     select @ellipsed = coalesce(@ellipsed + @separator, '') + token @tokens       return @ellipsed  end 

then coul call created function

select dbo.ellipsetextwords(details, 20, ' ', default) errorlog 

but wonder why dont in presentation layer.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -