Solved

XMLString In dynamic SQL call

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL server 2008 SP4 29 35
SQL JOIN 6 39
sql query to reportserver  table error 3 24
Caste datetime 2 25
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

747 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

10 Experts available now in Live!

Get 1:1 Help Now