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 2005 Forums
 Transact-SQL (2005)
 sql to xml?

Author  Topic 

palak
Yak Posting Veteran

55 Posts

Posted - 2008-05-07 : 13:20:58
i have one sql function...but i want xml file for this function how can i get it? any help would be appreciated. thanks

create function campaignquantity
(@campaign varchar(50), @startdate datetime, @enddate datetime)

RETURNS TABLE

AS

RETURN

( Select distinct t.campaign, t.itemnmbr, t.sumquantity as totalquantity

from

(

select distinct c.campaign, v.itemnmbr, sum(v.quantity)

as sumquantity , p.indx

From mySectionPubs P

inner join mycampaign C

on C.indx =P.indx and c.section_id = p.section_id

inner join vwitemnmbrquantity v

on v.itemnmbr=p.sku

Where c.campaign=@campaign and (v.docdate between @startdate and @enddate)

group by v.itemnmbr, p.indx, c.campaign

) t

)

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-05-07 : 13:22:18
select * from dbo.campaignquantity FOR XML AUTO

look up FOR XML in books online for more details and options

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-07 : 13:28:35
you have different formats of bulidng XML. Refer this:-

http://msdn.microsoft.com/en-us/library/ms345137.aspx
Go to Top of Page
   

- Advertisement -