Evaluate in T-SQL

后端 未结 11 2204
悲&欢浪女
悲&欢浪女 2020-12-17 23:42

I\'ve got a stored procedure that allows an IN parameter specify what database to use. I then use a pre-decided table in that database for a query. The problem I\'m having i

11条回答
  •  甜味超标
    2020-12-18 00:02

    declare @sql varchar(256);
    set @sql = 'select * into ##myGlobalTemporaryTable from '+@dbname
    exec sp_executesql @sql
    
    select * from ##myGlobalTemporaryTable
    

    copies into a global temporary table which you can then use like a regular table

提交回复
热议问题