1

I've a SQL statement that returns a xml result, for a serialized object.I want to add a attribute to an element, that reflects the type of the object "xsi:type=table" but i don't know how?

1
  • Please post the query... Commented Nov 15, 2010 at 2:19

1 Answer 1

3

Could use some additional information on your problem, but here goes:

SELECT TOP 10 SomeId, COUNT(1) SomeValue
INTO #SomeTable
FROM (SELECT ABS(CAST(NEWID() AS binary(6)) % 1000) + 1 SomeId
      FROM sysobjects) sample
GROUP BY SomeId;

WITH XMLNAMESPACES (N'http://www.w3.org/2001/XMLSchema-instance' as xsi)
SELECT SomeId "@SomeId",
       -- here is where you specify the type to put in the attribute
       'table' "@xsi:type",
       SomeValue
FROM #SomeTable
FOR XML PATH('AnElement'), ROOT('RootElement')

DROP TABLE #SomeTable;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.