I am calling a stored procedure in OpenQuery
and passing parameters to the stored procedure.
declare @Src nvarchar(max),@Tgt nvarchar(max)
declare @sql_str nvarchar (4000)
set @Src = '$\VMT\Versions\0900\AMS\'
set @Tgt = '$\VMT\Versions\0900\Base\'
set @sql_str = 'exec [Tfs_VMT Collection].dbo.MergeCandidate ''' + @Src+ ''' , ''' +@Tgt+''' '
set @sql_str = 'select * into #test from openquery(ODSSERVER,''' +Replace(@sql_str,'''', '''''') +''')'
print @sql_str
EXEC (@sql_str)
but this fails with following error
Msg 7357, Level 16, State 2, Line 1
Cannot process the object "exec [Tfs_VMT Collection].dbo.MergeCandidate '$\VMT\Versions\0900\AMS\' , '$\VMT\Versions\0900\Base\' ". The OLE DB provider "SQLNCLI10" for linked server "ODSSERVER" indicates that either the object has no columns or the current user does not have permissions on that object.
I have checked this has nothing to do with permissions.
Can you please help?