Hi guys, I have a question.
I need to transfer a query's result from a tab to another tab without having it saved on disc.
For example, i want to transfer the query's result from #FIRST_TABLE to #RET_TABLE, through a variable or whatever
IF OBJECT_ID('TEMPDB..#FIRST_TABLE') IS NOT NULL DROP TABLE #FIRST_TABLE
IF OBJECT_ID('TEMPDB..#RET_TABLE') IS NOT NULL DROP TABLE #RET_TABLE
CREATE TABLE #FIRST_TABLE(ROW_ONE INT, TEXTON2 VARCHAR(100))
CREATE TABLE #RET_TABLE(FILENAME VARCHAR(255), FILEBINARY VARBINARY(MAX))
DECLARE @VARBINARY VARBINARY(MAX), @VARFILENAME VARCHAR(255)
INSERT INTO #FIRST_TABLE VALUES
SET @VARFILENAME = 'PIPPO.CSV'-- the format is not important as long as the type is known
SET @VARBINARY = ???? -- this is supposed to be the result of the query "SELECT * FROM #FIRST_TABLE"
INSERT INTO #RET_TABLE VALUES
DROP TABLE #FIRST_TABLE
--DROP TABLE #RET_TABLE
-- from #RET_TABLE i want to recover the result from a binary field into a file