Reply to Re: AttribDescription as calculated field

Your name:

Reply:


Posted by Erland Sommarskog on 06/28/05 01:06

Axel (realraven2000@hotmail.com) writes:
> in T-SQL,
>
> (how) is it possible to concatenate 3 (varchar) fields into one; either
> in a SQL query or through a calculated field (or using a view, if
> anybody can explain to me how to use views), according to the following
> rules:
>
> {
> first 30 chars of Trim(AttributeVal1)
>
> if resulting string<30 chars append
> ", " & first 30 chars of Trim(AttributeVal2)
>
> if resulting string<30 chars append
> ", " & first 30 chars of Trim(AttributeVal3)
> }
>=> define as new field StockItemDescription

SELECT str30 = substring(rtrim(AttributeVal1)), 1, 30)
CASE WHEN len(AttributeVal1) < 30
THEN ', ' + substring(rtrim(AttributeVal2)), 1, 30)
CASE WHEN len(AttributeVal1) + 2
len(AttributeVal2) < 30
THEN ', ' + substring(rtrim(AttributeVal3)), 1, 30)
ELSE ''
END
END

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация