Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

XMLString In dynamic SQL call

Posted on 2012-03-23
1
Medium Priority
?
124 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 2000 total points
ID: 37760238
Needs to be treated like a string so put single quotes around your XML
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
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 combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

885 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