Back
Theme:

Como fazer um SELECT INSERT usando Storage Procedure


Como eu faço para fazer um SELECT INSERT usando Storage Procedure?

Date: Monday, February 20, 2023
2 answers | 210 view(s)
by Mauricio Junior

Answers

Veja se isso ajuda... Estou pegando os dados da tabela 2 e inserindo na tabela 1.

Veja o código abaixo:

CREATE PROCEDURE [dbo].[PROCEDURE_NAME]

	@PARAM_1		AS INT,
	@PARAM_2		AS NVARCHAR(50)

AS

	INSERT INTO 
		Table2 
			(CH_TB1, VALOR_TB2, NOME_TB2, DT_TB2, DESCRICAO_TB2)
			(SELECT 
				CH_TB1,VALOR_TB1, NOME_TB1, DT_TB1,  @PARAM_2
			FROM 
				Table1 
			WHERE 
				CH_TB1 = @PARAM_1)

Monday, February 20, 2023

Mauricio Junior


Estou inserindo na tabela 2 o que eu pego da tabela 1.

Monday, February 20, 2023

Mauricio Junior


Finanças na prática