0
Hello fellow collaborators...
I have a server that has more than 100 banks, and most are of the same structure.
I would like to create a function, process or whatever. That could expedite my maintenance.
I thought about the possibility of having an array named after these banks, and reading this array and firing the necessary commands.
I haven’t gotten results yet, see the following code to see if you understand me:
DECLARE @arrayMinhaBase = [
0 -> "nomeDoBancoUm",
1 -> "nomeDoBancoDois",
2 -> "nomeDoBancoTres",
3 -> "nomeDoBancoQuatro",
4 -> "nomeDoBancoCinco",
5 -> "nomeDoBancoSeis"
-- etc -> "nomeDoBanco"
];
DECLARE @totalBase int = 1;
DECLARE @chave int;
SET @chave = 0;
SET @totalBase = count(@arrayMinhaBase);
WHILE @chave <= @totalBase
BEGIN
SELECT * FROM @arrayMinhaBase[$chave].nomeDaTabela;
END
Well, whatever I get the closest to expediting this process, I’m grateful. The above example I used a select, but most of the time it is to run an alter table or update.
Already took a look at sp_msforeachdb?
– Fábio Pietro