Back
Theme:

Como inserir valores em uma tabela temporária pegando o que vem da stored procedure?


Como inserir valores em uma tabela temporária pegando o que vem da storage procedure?

Date: Thursday, June 29, 2023
2 answers | 154 view(s)
by Mauricio Junior

Answers

Primeiro passo é declarar a sua tabela temporária.

Declarando a tabela

DECLARE @RawData TABLE
(
	ClassifierID VARCHAR(255),
	ClassifierLogID VARCHAR(255),
	ScanId VARCHAR(255),
	Well VARCHAR(255),
	ClassifierVer VARCHAR(255),
	ClassifierImage VARCHAR(255),
	ClassifierParameters VARCHAR(255),
	State INT,
	Seed_Length FLOAT,
	Seed_Width FLOAT,
	Seed_Area FLOAT,
	Seed_Other VARCHAR(255),
	Root_Length FLOAT,
	Root_Area FLOAT,
	Root_Thickness FLOAT,
	Root_Other VARCHAR(255),
	Stem_Length FLOAT,
	Stem_Area FLOAT,
	Stem_Height float,
	Stem_Other VARCHAR(255),
	Leaf_Area float,
	Leaf_Height float,
	Leaf_Chlorophyll float,
	Leaf_Other VARCHAR(255),
	Notes VARCHAR(255),
	ConditionFlags int,
	ContainerId NVARCHAR(20),
	ScanNum INT,
	ShardName NVARCHAR(MAX)
)

Inserindo valores retornados da storage procedure

INSERT INTO @RawData (ClassifierID, ClassifierLogID, ScanId, Well, ClassifierVer, ClassifierImage, ClassifierParameters, 
	[State],
	Seed_Length,
	Seed_Width,
	Seed_Area,
	Seed_Other,
	Root_Length,
	Root_Area,
	Root_Thickness,
	Root_Other,
	Stem_Length,
	Stem_Area,
	Stem_Height,
	Stem_Other,
	Leaf_Area,
	Leaf_Height,
	Leaf_Chlorophyll,
	Leaf_Other,
	Notes,
	ConditionFlags,
	ContainerId,
	ScanNum,
	ShardName) 
execute [YOUR_PROCEDURE] @parameters;

Thursday, June 29, 2023

Mauricio Junior


Espero ter ajudado e qualquer dúvida pode entrar em contato.

Thursday, June 29, 2023

Mauricio Junior


Learn database step by step in practice