Hi All,
I have a table value function, here's the code:
ALTER FUNCTION [dbo].[GetJobApplicantsFromMySQL] ( -- Add the parameters for the function here ) RETURNS TABLE AS RETURN ( -- Add the SELECT statement with parameter references here SELECT * FROM OPENQUERY(MySQL, 'SELECT 3 AS JobPostingOption, user_id AS Id, CONCAT(firstname , '' '', lastname ) AS Name, email AS Email, '''' AS ResumeFullPath FROM vantage_db.wpjb_resume') )
Its running perfectly fine but now I have different requirement I have to use same query on different databases, I came across this article: http://support.microsoft.com/kb/314520?wa=wsignin1.0 and I decided to give it a try and I come up with this TSQL for testing purpose :
DECLARE @VAR varchar(64)
SELECT @VAR = 'vantage_db'
EXEC MySQL.master.dbo.sp_executesql
N'SELECT 3 AS JobPostingOption, user_id AS Id, CONCAT(firstname , '' '', lastname ) AS Name, email AS Email, '''' AS ResumeFullPath FROM @DBName.wpjb_resume',
N'@DBName varchar(64)',
@VARBut it's giving me the following error:
OLE DB provider "MSDASQL" for linked server "MySQL" returned message "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.". Msg 7212, Level 17, State 1, Line 3 Could not execute procedure 'sp_executesql' on remote server 'MySQL'.
Any ideas?
Thanks,
Attiqe
Attiqe Ur Rehman