1
I need to make multiple inserts that will depend on an existing result in a table like this:
--CRIA TABELA #CONTATO
CREATE TABLE #CONTATO(
NOME VARCHAR(100) NULL,
TELEFONE VARCHAR(50) NULL
);
--INSERE 2 LINHAS NELA
INSERT INTO #CONTATO VALUES('JOAO','11-1111-1111');
INSERT INTO #CONTATO VALUES('MARIA','22-2222-2222');
Imagine who in the example above I need my result to be something like:
PRINT 'MEU NOME É '@NOME+' E MEU TELEFONE É '+@TELEFONE;
Could someone show me what dynamic SQL I would do, because I’ve seen examples on the internet that use the sp_executeSQL
but I couldn’t figure out how to manipulate when there’s this case... the return I’d like to have would be something like
--MEU NOME É JOAO E MEU TELEFONE É 11-1111-1111
--MEU NOME É MARIA E MEU TELEFONE É 22-2222-2222
It’s not very clear what you want. The idea is to execute what, exactly?
– Leonel Sanches da Silva
I need that, for each row that exists inside the table #contact, I can through a sp_executeSQL() take information from this line, execute a command; then pass to the next and bla bla bla...
– LeandroLuk