How to handle dynamic XMLNAMESPACE

  • I have a situation where an XMLNAMESPACE has a URL that needs to be dynamic. Its being used with an insert into a table from an XML parameter passed in my stored procedure as the source.

    Setting a variable and placing it in the XMLNAMESPACE generates an error

    ;WITH XMLNAMESPACES(DEFAULT 'http://www.microsoft.org/2005/Atom', @Base_Namespace, 'http://schemas.microsoft.com/ado/2007/08/dataservices' AS d, 'http://schemas.microsoft.com/ado/2007/08/dataservices/metadata' as m)

    I tried building the Entire Insert Statement concatenating the dynamic url but then I get an error saying that the sp_ExecSQL needs the XML parameter defined.

    Is there a way to make the URL dynamic in the XMLNameSpace?

  • Figured out to do it. I passed the XML in as a parameter

    EXEC sp_ExecuteSQL @Dynamic_Insert, N'@XMLResponse XML', @XMLResponse = @XMLResponse

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply