Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 variable table names with a twist

Author  Topic 

smccreadie
Aged Yak Warrior

505 Posts

Posted - 2001-09-27 : 09:37:49
I'm attempting to use robvolk's code to create a dynamic cross-tab stored procedure, however the use of global temp tables is a problem because users will be trying to run this at the same time.

Is there a way to append the @@SPID onto a global temp table name so that these tables are can be referenced uniquely?

For example, the following doesn't work but you can see what I'm trying to do:

DECLARE @TableName varchar(100)
SET @TableName = '##test2'+@@SPID
DECLARE @SQL nvarchar(1000)

SELECT @SQL = 'Create Table ' + @TableName + '(ID int)'

Exec (@SQL)




   

- Advertisement -