简体   繁体   English

如何从SQL中的临时表(#temp1)生成脚本

[英]How to Generate script from Temporary table (#temp1) in SQL

I tried to Generate Script From Temporary table , let we say my temp table is temp1 like below 我试图从临时表生成脚本,让我们说我的临时表是temp1,如下所示

select * into #temp1 from Receiptsandpayments

This #temp1 Table stored in systemDatabase under Tempdb 此#temp1表存储在Tempdb下的systemDatabase中

When I Tried to Generate Script From #temp1, I can't able to Generate Script 当我尝试从#temp1生成脚本时,我无法生成脚本
Is there any way to Generate Script from #temp Table 有没有办法从#temp表生成脚本
please Help me to tackle this issue..... 请帮我解决这个问题.....

Temporary tables can only be accessible within the same SQL session. 临时表只能在同一SQL会话中访问。 If you want your temporary table to be accessible across multiple sessions you can try creating global temporary tables (add 2 # in the table name): 如果希望可以跨多个会话访问临时表,可以尝试创建全局临时表(在表名中添加2#):

eg: select * into ##temp1 from Receiptsandpayments 例如:从Receiptsandpayments中选择*到## temp1

After that, try to run your Generate script again, this time querying ##temp1 instead of #temp1. 之后,尝试再次运行Generate脚本,这次查询## temp1而不是#temp1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM