I have a stored procedure which returns 2 resultset each containing exact one cell. In first one I am returning an xml and in second a datetime value.
I tried accessing this SP (SP_XML) from a linked server which failed saying XML not allowed on linked server. So I wrote a wrapper (SP_NChar) like below. The thing is I need only the XML resultset across linked server and not the datetime resultset(it does not matter if I receive it or not)
CREATE PROCEDURE SP_NChar
AS
BEGIN
-- TO STORE PROC RESULT
DECLARE @XML_RESULT TABLE(result XML)
BEGIN TRY
INSERT INTO @XML_RESULT(result) EXEC SP_XML
SELECT CAST(result AS NVARCHAR(MAX)) FROM @XML_RESULT
END TRY
BEGIN CATCH
-- This block will get executed because one is XML and another is Datetime and it will fail in try part
PRINT 'Do Nothing'
select * from @XML_RESULT
END CATCH
END
It works as expected on my dev environment, but fails on prod environment, any idea what might go wrong.
Just for testing purpose here SP_XML
CREATE procedure SP_XML
as
BEGIN
select CAST('<ROOT>2</ROOT>' AS XML)
select getdate()
END