I have a stored procedure which creates a temporary table with found indexes by using CONTAINSTABLE like (I put a piece of stored procedure code):
CREATE TABLE #tmpTable(
ID INT,
RANK INT)
SELECT @query = '
SELECT
DISTINCT ID AS T_ID,
indexTable.RANK AS RANK
FROM
MyTable
INNER JOIN
CONTAINSTABLE(MyTable, (*), "ISABOUT('example*')") AS indexTable
ON
MyTable.ID = indexTable.[KEY]
ORDER BY RANK DESC'
I want to use, if is possible, the temporary table into another stored procedure to use its values for other purpose and avoid to do twice same thing.
If is not possible then can you advice me the best way to re-use table data in different stored procedure. Also, I know that I cannot create view inside stored procedure then view is out of discussion.
Use GLOBAL temp tables
You can create a global temporary table by prefixing the table name with double hash(##)
Once this table has been created by a connection, like a permanent table it is then available to any user by any connection. It can only be deleted once all connections have been closed.
Edit:
In order to check for the existence of a temporary table you can use the following statement/check.