In SQL Server Management Studio 2012 have the possibility to create array in a procedure? I did a google search and did not find, it seems like a table variable is used to store more than one value from a select.
In SQL Server Management Studio 2012 have the possibility to create array in a procedure? I did a google search and did not find, it seems like a table variable is used to store more than one value from a select.
The only way I know it is how you said it, create (User-defined TABLE Type) as follows.
CREATE TYPE [dbo].[tp_IDsTable] AS TABLE(
[Id] [int] NULL
-- mais campos
)
GO
create PROCEDURE TestePassandoArray
@Id int
as
DECLARE @IDsTable tp_IDsTable -- aqui você criar um tipo como se fosse um array.
insert into @IDsTable
SELECT IdUsuario FROM tb_Usuarios where IdUsuario = @Id;
select * from @IDsTable
GO
EXEC TestePassandoArray 2