mardi 23 décembre 2014

Could be temporary table shared across sessions?


I have revised a procedure that builds a dynamic SQL statement that creates and populates a temporary table. The syntax was something like this:



...`create #temp_` + CAST(GETGUID() AS VARCHAR(36)) ...


I ask a colleague if he knew why a unique identifier is concatenated to the table name. He told me that in the past, there were cases when temporary tables were shared across sessions and the data was messed up.


I know this is not possible since in the MSDN is clearly said that:



You can create local and global temporary tables. Local temporary tables are visible only in the current session, and global temporary tables are visible to all sessions.



Now (remembering the case) some colleagues things we should use the syntax above as a good practice but I do not like it and need a proof there is no such bug or if it was it is already fixed.


Could anyone with experience in SQL Server 2005/2008 tell if there was such case?





Aucun commentaire:

Enregistrer un commentaire