I have taken this function from https://stackoverflow.com/a/9714484/1678652
SET @XML = N'<root><r>' + REPLACE(@s, @sep, '</r><r>') + '</r></root>'
INSERT INTO @result(Id)
SELECT DISTINCT r.value('.','int') as Item
FROM @xml.nodes('//root//r') AS RECORDS(r)
It takes a string and splits into a table wth an element in each row. It works when I test it in SSMS, but when I call it from the websserver (php/pdo) it returns an empty result set.
I think it must be something with XML permissions, because if I let the function add hardcoded results into the table, I do get the results back to php.
If I hardcode parameters to the function, I do not get a result to php, and I can alter the function to just return the parameters, so it is not an input issue.
I wonder if this is relevant:
http://beingoyen.blogspot.dk/2009/06/tsql-error-execute-permission-denied-on.html
Solution was simple: GRANT EXECUTE ON XML SCHEMA COLLECTION::{XMLSchema1} TO {RestrictedLoginName}
But what would this XML Schema collection be called? In SSMS i can browse for objects of the XML Schema collection-type for adding permissions to the user, but there is no objects of this type.
I have granted all permissions on the function to the user.