Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

XMLString In dynamic SQL call

Posted on 2012-03-23
1
Medium Priority
?
121 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

704 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