Does SSRS 2008 support the XML Datatype in SQL Queries?
I have an query that uses the XML data type. (You can see the query here.) Just to be clear that means that my query has something like this in it: declare @xmlDoc XML When I try to paste my query in as a Dataset for a SQL Server Reporting Services Report in BIDS (Visual Studio 2008) a dialog pops asking me to define my parameters: The problem is that I don't have any Parameters! I define and use @xmldoc in the query (it runs with no issues in SSMS). It does not really seem to matter what I enter here. This is always the next dialog box: "OK" closes the Dataset properties and I get no fields setup for me. "Cancel" gets me back to the properties to try again. If I put in a query without the XML data type then it works fine. I am stumped... I can only conclude that SSRS does not support the XML data type. Is this true? If it is, is there a work around? I have my query all done and I would rather not have to re-do it with OPENXML.
May 24th, 2011 6:52pm

Hello Vaccanoll, SSRS supports only queries returning a single resultset (let's say only a single select statement); not such complex queries. Create a stored procedure with your query and use the SP as dataset source. In SSRS query designer all names starting with @ are interpreted as parameter passed from SSRS to the query; therefor SSRS prompts to get a value for @xmlDoc.Olaf Helper * cogito ergo sum * errare humanum est * quote erat demonstrandum * Wenn ich denke, ist das ein Fehler und das beweise ich tglich Blog Xing
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2011 12:53am

Turns out that the XML Data type is supported in SSRS, you just can't declare a variable of type XML. The fix is to cast a varchar to xml in a ;with statement. That way you don't have to declare an XML variable. Here is a short example to illustrate: -- actual xml of the test case's steps DECLARE @docParam varchar(max) <br/>-- Add the XML to @docParam <br/> ; With c as(SELECT CAST(@docParam as XML) DocParams) select TBL.SParam.value('local-name(.)[1]', 'varchar(50)') as Name from c CROSS APPLY DocParams.nodes('/NewDataSet/Table1[1]/*') as TBL(SParam) @Olaf Helper - Thanks for your reply. I appreciate you taking time to reply to my question. But I must say that your response does not add up to me. I have done far far more complex queries directly in SSRS than this one (ones with loops and several OPENXML calls, many select statements that fill temp tables and 20+ declarations of @vars that are not parameters). The issue turned out to be the XML var. That is just not supported in SSRS (so it seems). You were right that adding a sproc would have fixed it. But this is not my database, so adding a sproc would be less than ideal (and make my report non-portable). As a side note, the fix was given to me here.
May 25th, 2011 12:12pm

So the actual problem was that the capitolization was mixed. My var was declared as @xmlDoc but I was using it as @xmldoc. That confuses BIDS.
Free Windows Admin Tool Kit Click here and download it now
May 25th, 2011 5:12pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics