Jump to content

Undeclared prefix for SQL Server 2012


llewis
 Share

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>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...