19-11-2010, 13:51
|
|
|
חבר מתאריך: 18.11.10
הודעות: 2
|
|
קבלת תוצאות שאילתת XML ב STRING
שלום לכולם,
יש לי שאילתת SQL והיתי רוצה לקבל את התוצאות של הXML ב STRING אחד ארוך.
לדוגמא:
USE [smart buy]
GO
/****** Object: StoredProcedure [dbo].[spSerchByNumber] Script Date: 11/19/2010 14:49:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- DEMO : spSerchByNumber @Product_num=8316
ALTER procedure [dbo].[spSerchByNumber]
@Product_num bigint
as
select 1 as tag,
null as parent,
null as [Products!1],
null as [Product!2!ID],
null as [Product!2!Name],
null as [Product!2!compeny_name],
null as [Product!2!category_name],
null as [Product!2!sub_category_name],
null as [Product!2!Price],
null as [Product!2!Gold_price],
null as [Product!2!Weight],
null as [Product!2!Description1]
union all
select 2 as tag,
1 as parent,
null,
product_id,
product_name,
c.compeny_name,
cn.category_name,
sc.sub_category_name,
price,
gold_price,
weight,
description1
from dbo.Products p,
dbo.COMPENY c,
dbo.CATEGORIES cn,
dbo.sub_category sc
where p.compeny_id = c.compeny_id
and
cn.category_id=p.category_id
and
sc.sub_category_id=p.sub_categoty_id
and
p.product_id=@Product_num
for xml explicit
והתוצאות:
<Products>
<Product ID="8316" Name="ביצים ארוזות 30" compeny_name="מן הטבע " category_name="ביצים ומוצרי חלב " sub_category_name="ביצים" Price="3.015000000000000e+001" Gold_price="2.990000000000000e+001" Description1="XL ביצים ארוזות מן הטבע 1/30 גודל " />
</Products>
מי יכול להגיד לי אך אני מקבל את התוצאה כסטרינג????
תודה..
|