I implement and support a software applicatoin that allows me to create macros within the application. One of the macro steps is to execute a SQL procedure. When I attempt to run a macro that is executing a stored proc (_TSi_CustomerAccountCorrection) I'm seeing this error:
Error 0 executing [__TSi__CustomerAccountCorrection].
Invalid object name 'TSI_ProService.dbo.Customer'.
If I run this stored proc in SQL Query Analyzer (SQL 2000 using Integrated Security), the proc runs just fine. The application I'm running it through uses a SQL connection string that is set to use integrated security and I'm logged on as the same exact user as well.
Unfortunately, I do not have the source code for the application. I was hoping that someone might recognize what is going on here or at least give me a suggestion as to what the issue might be.
As far as I can see, when running the stored proc through the application and through the query analyzer is exactly the same.
Here is the stored proc:
CREATE PROCEDURE [dbo].[__TSi__CustomerAccountCorrection] AS
set xact_abort on
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
BEGIN TRANSACTION trans1
DECLARE cur_cust CURSOR FOR
SELECT [AccountNumber] FROM DBSTR1.HQ.dbo.PSD_CustomerExport
DECLARE @accountNumber varchar(50);
DECLARE @custAccountNumber varchar(50);
DECLARE @query varchar(500);
OPEN cur_cust;
FETCH NEXT FROM cur_cust INTO @accountNumber;
WHILE @@FETCH_STATUS = 0 BEGIN
set @custAccountNumber = (SELECT TOP 1 [Account] FROM [Customer] WHERE [UserData2] = @accountNumber)
if @custAccountNumber is null
begin
SET @custAccountNumber = @accountNumber
end
--UPDATE DBSTR1.HQ.dbo.PSD_CustomerExport SET [VcrAccountNumber] = @custAccountNumber WHERE [AccountNumber] = @accountNumber
UPDATE DBSTR1.HQ.dbo.PSD_CustomerExport SET [VcrAccountNumber] = @custAccountNumber WHERE CURRENT OF cur_cust
FETCH NEXT FROM cur_cust INTO @accountNumber;
END
CLOSE cur_cust;
DEALLOCATE cur_cust;
COMMIT TRANSACTION trans1
GO
Any suggestions?