I have three temp tables from my query. Only one of them will be created, depending on the values set to variables. I dont know which table will be created, but it will be one of these three. The problem is that the table that is created needs to be sent through further analysis within the query and the queries below only accept one temp table name, #tmpPCTmodelClient. So I need to take the one table that is created and place it into the temp table #tmpPCTmodelClient. I wrote the code below, which works, but how can I use this code, or code like this, to insert the data from one of these tables into the one table?
if OBJECT_ID('tempdb..#TMPpatTable') is not NULL
begin
SELECT * FROM #TMPpatTable --- One of the tables that might be created
end
else if OBJECT_ID('tempdb..#TMPscTable') is not NULL
begin
SELECT * FROM #TMPscTable --- One of the tables that might be created
end
else if OBJECT_ID('tempdb..#TMPfsTable') is not NULL
begin
SELECT * FROM #TMPfsTable --- One of the tables that might be created
end
Aucun commentaire:
Enregistrer un commentaire