Forum Discussion
Can't use Temp Tables - really?
krypto6969You could try making your insert logic dynamic. As an example, I've used the script outlined in this blog to pull in SQL metrics, so I know it works. But you would most likely do something utilizing EXEC against a variable or sp_executesql like here
Or.. I just figured this out. For some reason if you wrap your Sproc in a variable, it works. So just build a sproc for the below code and you can run it like this. (Import only, Direct Query doesn't work)
DECLARE @sqlCommand varchar(1000)
SET @sqlCommand = 'dbo.Testproc'
EXEC (@sqlCommand)
What if using SPROC is not an option? where we want to use the data from production however for a temporary period to monitor and make a business case.
Need to use temp tables to create some metrics and keep running it for few days/weeks.. can't dump all production data to other environments. Don't want to create/run jobs to load the metrics into actual tables. If temp tables can be used no more an issue.
Has anyone found a good solution about using temp tables, please share...