Is there an easy way to use this setup or similar on a CROSS SERVER?
[CODE SQL]IF OBJECT_ID('tempdb..#MyTempTable') IS NOT NULL DROP TABLE #MyTempTable[/CODE]
I'm able to do it on the current server, but apparently not the connected server?
I know I can create temp tables on the connected server. For instance, this works:
But I can't seem to get anything to work to check for existence of and delete that same temp table. I have tried these variations so far with no luck:
and
and
Can anyone point me in the right direction? Does this method just not work on cross server operations, or else is there a different way I can carry out the same cleanup task? I basically want to check for existence of and delete the temp tables up front, in case I (or someone else behind me) ends up running the script multiple times in testing.
Thanks for any thoughts.
"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
[CODE SQL]IF OBJECT_ID('tempdb..#MyTempTable') IS NOT NULL DROP TABLE #MyTempTable[/CODE]
I'm able to do it on the current server, but apparently not the connected server?
I know I can create temp tables on the connected server. For instance, this works:
Code:
SELECT 1 AS TestID INTO ConnectedServer.#Test
SELECT * FROM ConnectedServer.#Test
But I can't seem to get anything to work to check for existence of and delete that same temp table. I have tried these variations so far with no luck:
Code:
IF OBJECT_ID('ConnectedServer.tempdb..#Test') IS NOT NULL DROP TABLE ConnectedServer.Test
Code:
IF OBJECT_ID('ConnectedServer.tempdb.#Test') IS NOT NULL DROP TABLE ConnectedServer.Test
Code:
IF OBJECT_ID('ConnectedServer.#Test') IS NOT NULL DROP TABLE ConnectedServer.Test
Can anyone point me in the right direction? Does this method just not work on cross server operations, or else is there a different way I can carry out the same cleanup task? I basically want to check for existence of and delete the temp tables up front, in case I (or someone else behind me) ends up running the script multiple times in testing.
Thanks for any thoughts.
"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57