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.
| Author |
Topic |
|
heze
Posting Yak Master
192 Posts |
Posted - 2007-03-08 : 13:12:21
|
| Hi,I am trying to assign an XML string to a varchar variable like this:----------declare @tableContainer as varchar(8000)set @tableContainer=(select * from myTable FOR XML AUTO)--------------This was unsuccesful--My final objective is to read the @tableContainer variableinto another table. That is, so that I can pass tables as parameteres and retunr them as strings, is it possible to accomplish this in SQL Server 2000? thank you |
|
|
heze
Posting Yak Master
192 Posts |
Posted - 2007-03-08 : 18:45:30
|
| Found a solution,Build the xml string in the stored proc that creates a table and set the output variable of that procedure to that string,for example, in a table of 1 column: declare @myStr as varchar(8000) set @myStr='<ROOT>' select @myStr=@myStr+'<row '+' EntryTermDesc="'+EntryTermDesc+'"''></row>' from ##GradRatesVertical set @myStr=@myStr+'</ROOT>' if (len(@myStr)<8000) set @xmlDocSerializedString=@myStr else print 'Error, xml string must be less than 8000 characters'--where @xmlDocSerializedString is the output variable of the procedure now, wherever somebody calls the procedure, that string will be available to consume as needed, its a little bit messy but great alternative to global temporal tables and comma separated table strings, the good thing about this is that with OPENXML one can transform the xml string produced by the procedure into a relational table with just a simple query, if somebody could add to this would be greatly appreciatedthank you |
 |
|
|
|
|
|