Solved

XMLString In dynamic SQL call

Posted on 2012-03-23
1
116 Views
Last Modified: 2014-03-25
I am trying to make a call to a linked server from a stored procedure and execute a store procedure. For some reason the XMLString does not want to format

Dynamic String
      set @SQLSTRING = ('INSERT  #xxx EXECUTE ' +  @ALIAS + '.' + @Database + '.[dbo].[prcMultiItemPriceSelect]  ' + @KUNNR + ', '  + @VKORG + ','  + cast(@MATNR as ))


Text produced
INSERT  #xxx EXECUTE GM_DYNAMIC_2.dynamic_0100_A10.[dbo].[prcMultiItemPriceSelect]  0038050762, 0100,<MATNR><ID>000000000010101328</ID><ID>000000000010481360</ID><ID>000000000010547647</ID><ID>000000000010552930</ID><ID>000000000010491270</ID><ID>000000000010262167</ID><ID>000000000010252864</ID><ID>000000000010252787</ID><ID>000000000010252842</ID><ID>000000000010252788</ID></MATNR>

Error produced
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '<'.
0
Comment
Question by:dkochenour
1 Comment
 
LVL 51

Accepted Solution

by:
Mark Wills earned 500 total points
ID: 37760238
Needs to be treated like a string so put single quotes around your XML
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question