I have a strange issue,
When I create a cursor to go and do some work on all my DBs, sometimes it does the work only for the first few and then stops with no output.
i.e. I have a job that runs a cursor on all my DBs and does a reindex on each of them, using a script I wrote for determining which reindex options should be used for each table.
I have very big DBs (all together 5TB), and the number of DBs are dozens.
If I replace the inner script of the cursor with a print of the DB name or any other light process, it runs on all the DBs, but when running it on a heavy job, will stop in the middle.
The above cursor runs as a step in a job (inside a maintenance plan by SSIS).
Today I was searching for a string in all my tables all over the server, so I created a dynamic script to select top 1 where column like ‘%string%’ on all my tables , and it ran only a few of them, the above was ran from the SSMS query window. So I copied the script again on the same window (meaning still on the same session) and had first cursor running on all DBs where the name < I and then again created the same cursor (same name) for all DBs where name > I and it completed the work.
I assume it is something to do with memory or other resource.
Do you know what can I do to have it run over all the DBs in the same cursor?