Jump to content
Sign in to follow this  
llewis

Undeclared prefix for SQL Server 2012

Recommended Posts

Please help! I am new to implementing xml within SQL. I'm trying to create a stored procedure that creates an xml node when a user enters data within my website. Below is a sample of my stored procedure. I have tried to declare the namespace within the insert however I continue to receive the "undeclared prefix" error message.

 

Code:

DECLARE @Term XML = '<wma:Term>My First Term</wma:Term>'DECLARE @x XML SELECT 	   @x = MetaDataFROM [Products] WHERE ID = 1SET @x.modify ('declare namespace wma="http://www.google.com/wma"; insert sql:variable("@Term") as last into (/wma:WMA/wma:List)[1]

Expected results:

<wma:WMA xmlns:wma="http://www.google.com/wma">  <wma:List>    <wma:Term>My First Term</wma:Term>  </wma:List></wma:WMA>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...