I'm trying to execute the following statement in a stored procedure:
-------------------------------------------
DECLARE @MyId int
DECLARE Monjacursor cursor for SELECT PersonId FROM ProntoRemote.pronto.dbo.person WHERE NOT PersonId IN (SELECT DISTINCT PersonId FROM attendance)for read only
OPEN Monjacursor
FETCH NEXT FROM Monjacursor INTO @MyId
WHILE @@FETCH_STATUS = 0 BEGIN INSERT INTO Attendance(PersonId,UpdateDate,CreateDate) VALUES(@MyId,GetDate(),GetDate())
FETCH NEXT FROM Monjacursor INTO @MyId END
CLOSE Monjacursor DEALLOCATE Monjacursor
--------------------------------------
It works fine in Query Analyzer but I get the following errormessage when i try to save the stored procedure.
"Error 7405: Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these option and then reissue your query."
I tried to set the ANSI_NULL and ANSI_WARNINGS to ON in the stored procedure but this did not help.
I cant really see any problems. The ERROR does mention the connection and I can see that your selecting from another server/dB so it may have something to do with that!
Are you saying that you can actually RUN the SP in Query Analyzer, you are not just checking the syntax?
Another thing! Why dont you just make a INSERT INTO .... Select instead of looping? This may simplify things some!
By 'OTHER', do you mean the remote, linked server? The remote server is not accesible through QA since it is a 'virtual' server. However, I can view it's tables through EM.
Yes I did mean the linked server, but as you say it isnt in the list.
Dont know what to suggest then :o(
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.