I have written some script that runs the BCp to execute a stored procedure and output the results to a file.
DECLARE @return_value int
DECLARE @strbcpcmd NVARCHAR(2000)
set @strbcpcmd = 'bcp "exec [BPSD].[dbo].[SKL_XML_Export_InitialLoad] @StartDate = ''2013-11-01'', @EndDate = ''2014-09-30''" queryout "d:\nasher\bpsd\2013.xml" -w -C OEM -t"$" -T -S -U xxx -P xxxxx'+@@servername
EXEC master..xp_cmdshell @strbcpcmd
It works fine on my local SQL Server 2012 machine but when i deploy it to the live server (which is SQL Server 2008) i get the following error:
SQLState = 37000, NativeError = 5302
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Mutator 'modify()' on '@Aviseringsinformation' cannot be called on a null value.
I have looked for this error but can not find any reference to it. I suspect that it could be a permission error because i can run the sp manually. Also the second line refers to update a node that does not exist but i know that that it should.