Hi,
i have the following requirement
Can a stored procedure in SQL Server 2005 generate XML data based on the schema, We don't prefer to manually build an xml string inside the stored proc?
Is there any SQL Server 2005 feature to do it if possible?
i appreciate your help.
Thanks,
Vaishu
Can a stored procedure in SQL Server 2005 generate XML data based on the schema?
Yes...
Create Proc dbo.GenXMLWithSchemaValidation
As
Begin
Set Nocount On
DECLARE @.x XML (HumanResources.HRResumeSchemaCollection)
SET @.x = (
SELECT ContactID,
FirstName,
LastName,
AdditionalContactInfo.query('
declare namespace aci="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactInfo";
declare namespace act="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ContactTypes";
//act:telephoneNumber/act:number') as MorePhoneNumbers
FROM Person.Contact
FOR XML AUTO, TYPE)
SELECT @.x
Set Nocount Off
End
Hope this helps,
Derek
|||Thanks Derek
i appreciate your help.
Vaishu
No comments:
Post a Comment