Solved

XMLString In dynamic SQL call

Posted on 2012-03-23
1
113 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now