I am trying to execute a stored procedured from a linked database in MS SQL 2005. The linked database is a db2 database on a iseries server. I am using the iSeries IBMDASQL service provider. I am able to query the stored procedure without problems using a simple vbscript and ado. When I try to execute the same stored procedure in query analyzer on the SQL Server, I never see any results. Query analyzer always show ‘command executed’ and when I execute the select * on the temp table, no values appear. What am I doing wrong????? Thanks!
–code from query analyzer below–
DECLARE @emailToAddress char(50) DECLARE @emailFromAddress char(50) set @emailToAddress = 'customer.service@company.com' set @emailFromAddress = 'customer@gmail.com' If Object_ID('tempdb..#tmpResultTbl') Is Not Null Drop Table #tmpResultTbl Create Table #tmpResultTbl ( OUTPGMID Char(150)) --SET FMTONLY Off Set NoCount On Insert Into #tmpResultTbl EXEC ('CALL abicqual.VP_GETCCEPGMID(?, ?) ', @emailToAddress, @emailFromAddress) AT MAM400 Select * From #tmpResultTbl
UPDATED: Here is the updated code to use openquery… still no luck 🙁
DECLARE @TSQL varchar(8000) DECLARE @emailToAddress varchar(50) DECLARE @emailFromAddress varchar(50) SET @emailToAddress = ‘customer.service@company.com’ SET @emailFromAddress = ‘customer@gmail.com’ SET @TSQL = ‘SELECT * FROM OPENQUERY(MAM400,”CALL abicqual.VP_GETCCEPGMID(””’ + @emailToAddress + ””’, ””’ + @emailFromAddress + ””” + ‘)”’ + ‘)’ Print @TSQL EXEC (@TSQL)
–output below– SELECT * FROM OPENQUERY(MAM400,’CALL abicqual.VP_GETCCEPGMID(”customer.service@company.com”, ”customer@gmail.com”)’) Msg 7357, Level 16, State 2, Line 1 Cannot process the object ‘CALL abicqual.VP_GETCCEPGMID(‘customer.service@company.com’, ‘customer@gmail.com’)’. The OLE DB provider ‘IBMDASQL’ for linked server ‘MAM400’ indicates that either the object has no columns or the current user does not have permissions on that object.
Turns out that there are a number of issues with the IBMDASQL provider that I was using. Believe it or not it is faster and more reliable to use the Microsoft OLE DB Provider for ODBC Drivers. After creating a new linked server with this provider, all of my earlier sql attempts worked properly. Cheers!