2012-01-08 100 views
0

給出以下內容。由逗號分隔符的sql拆分字段

Products_Joined.METATAG_Keywords AS Keyword, 

這將返回此爲「關鍵字」

shoe,sneaker,boot,slipper 

我綁到這個分成單獨的領域等等。

keyword1 shoe 
keyword2 sneaker 
keyword3 boot 
keyword4 slipper 

像逗號分隔符上的JavaScript分割功能。

不幸的是,這是該字段如何存儲在數據庫中。

編輯:雖然我不認爲它很重要我已經提供了完整的SQL查詢,也許有人可以告訴這是哪個版本的SQL。

SELECT 
'home-and-garden-products > home decorations > rugs' AS Category, 
SUBSTRING(Products_Joined.ProductName, 6,LEN(Products_Joined.ProductName)) AS [stripHTML-Title], 
'Config_FullStoreURL' + 'ProductDetails.asp?ProductCode=' + Products_Joined.IsChildOfProductCode AS Link, 
Products_Joined.ProductCode AS SKU, 
CAST(IsNull(Products_Joined.SalePrice,Products_Joined.ProductPrice) AS VARCHAR(30)) AS Price, 
Products_Joined.ProductManufacturer AS Brand, 
Products_Joined.UPC_code AS UPC, 
'Config_FullStoreURLConfig_ProductPhotosFolder/' + IsNull(Products_Joined.IsChildOfProductCode,Products_Joined.ProductCode) + '-2T.jpg' AS Image, 
Products_Joined.ProductDescription AS [stripHTML-DESCRIPTION], 
Products_Joined.ProductManufacturer AS Manufacturer, 
Products_Joined.vendor_partno AS [Mfr part number], 
'0' AS [Shipping Cost], 
Products_Joined.Google_Color AS Color, 
Products_Joined.Google_Material AS Material, 
Products_Joined.ProductWeight AS [Shipping Weight], 
Products_Joined.Google_Size AS Size, 
Products_Joined.METATAG_Keywords AS Keyword, 
Products_Joined.ProductWeight AS Weight 
FROM Products_Joined WITH (NOLOCK) 
WHERE (Products_Joined.ProductPrice > 0) 
AND (Products_Joined.IsChildOfProductCode IS NOT NULL) 
ORDER BY Products_Joined.ProductCode 

回答

1

您可能會發現this page包含您正在尋找的解決方案。

希望它有幫助!

+0

嗯,不工作:( – user357034 2012-01-08 02:22:39

+0

以何種方式是不工作的錯誤信息或不正確的結果說明會嗎?如果你不介意, – LaKraven 2012-01-08 02:26:21

+0

我編輯了問題並添加了完整的查詢,不確定在哪裏添加你鏈接的代碼 – user357034 2012-01-08 02:28:50