Reputation: 31
I'm writing a stored procedure. I'll explain my problem with some sample code below.
-- Create a temp table
CREATE TABLE #FoundRequests
(
RequestID INT
);
SELECT RequestID
FROM Requests
-- Don't worry about the WHERE clause for now
Which returns a result set:
| ID | RequestID |
+------+-----------+
| 1 | 824 |
| 2 | 922 |
| 3 | 954 |
How would I get reach RequestID
from this result set and insert each found value into my temp #FoundRequests
table?
I tried different things like STUFF()
and SPLIT(@ID_VALUE , '')
but I can't get it to work.
Upvotes: 0
Views: 1023
Reputation: 1127
You could insert all records from Requests
table into #FoundRequests
with the following query:
insert into #FoundRequests(
RequestID INT
)
select RequestID from Requests;
If needed you can also add where clause into your select to filter results.
Upvotes: 1