Temp Table usuage in a Multi User Environment

耗尽温柔 提交于 2019-12-19 08:10:08

问题


here's the situation:

I have an SSRS report that uses an SP as a Dataset. The SP creates a Temp Table, inserts a bunch of data into it, and select's it back out for SSRS to report. Pretty straight forward.

Question:

If multiple users run the report with different parameters selected, will the temp table created by the SP collide in the tempdb and potentially not return the data set expected?


回答1:


Most likely not. If the temp table is defined as #temp or @temp, then you're safe, as those kind of temp tables can only be accessed by the creating connection, and will only last for the duration of the execution of the stored procedure. If, however, you're using ##temp tables (two "pound" signs), while those tables also only last for as long as the creating stored procedure runs, they are exposed to and accessible by all connections to that SQL instance.

Odds are good that you're not using ##tables, so you are probably safe.




回答2:


A temp table with a single # is a local temporary table and its scope is limited to the session that created it, so collisions should not be a problem.



来源:https://stackoverflow.com/questions/4725812/temp-table-usuage-in-a-multi-user-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!