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
 Transact-SQL (2000)
 How to concatanate several fields in given criteri

Author  Topic 

nalin_769
Starting Member

16 Posts

Posted - 2008-03-03 : 00:39:31
hi

This is my sql,

SELECT dbo._PRE_ORDER_COSTING.iCostingID, dbo._MAS_STYLE.sStyleID, dbo._PRE_ORDER_COSTING.sVariant, dbo._PRE_ORDER_COSTING.sRepeatID, dbo._PRE_ORDER_COSTING.sBuyNo,
dbo._MAS_STYLE.sStyleID + '-' + dbo._PRE_ORDER_COSTING.sVariant + '-' + dbo._PRE_ORDER_COSTING.sBuyNo + '-' + dbo._PRE_ORDER_COSTING.sRepeatID AS StyleID
FROM dbo._PRE_ORDER_COSTING INNER JOIN
dbo._MAS_STYLE ON dbo._PRE_ORDER_COSTING.iStyleCode = dbo._MAS_STYLE.iStyleCode
WHERE (dbo._PRE_ORDER_COSTING.OrderStatus = 0)

This is the result it given

iCostingID sStyleID sVariant sRepeatID sBuyNo StyleID

6 JR001 NA NA NA JR001-NA-NA-NA
7 JR005 NA NA NA JR005-NA-NA-NA
8 JR007 NA NA Jan-08 JR007-NA-NA-Jan-08

How can I concatanate fields except 'NA' value fields. like JR001 or JR005 or JR007-Jan-08



Thank You

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-03 : 01:09:05
Use CASE operator.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

nalin_769
Starting Member

16 Posts

Posted - 2008-03-03 : 01:23:47
Thank You
Go to Top of Page
   

- Advertisement -