I want to store values from a SELECT statement into a variable which is capable of holding more than one value because my SELECT statement returns multiple values of type INT. This is how my SP looks like so far.
ALTER PROCEDURE "ESG"."SP_ADD"
AS
BEGIN
DECLARE @Id table(identifiers VARCHAR);
INSERT INTO @Id (identifiers) VALUES('axaa1aaa-aaaa-a5aa-aaaa-aa8aaaa9aaaa');
INSERT INTO @Id (identifiers) VALUES('bxbb1bbb-bbbb-b5bb-bbb4-bb8bbbb9bbbf');
DECLARE @tranID INT = (SELECT
DOCUMENT_SET_.DOCUMENT_SET_TRANSACTION_ID
FROM DOCUMENT_SET_TRANSACTION
WHERE DOCUMENT_SET_TRANSACTION.IDENTIFIER IN (SELECT identifiers FROM @Id));
END
Variable @tranID should be a list or an array to hold the ids. Is it possible to do it SQL Server?
DECLARE @tranID TABLE (IDs INT);, then insert your data,INSERT INTO @tranID SELECT ID FROM ....Incorrect syntax near '='.if I declare it as a table@tranIDfrom there? Just return it to the client? If so just do aSELECTand don't "return" a value.