It is better to use a #temp table. Global temp tables can cause problems if the same stored procedure can be run more than once at the same time, or if some other stored proc uses the same global temp table name. Also, SELECT INTO can cause a schema lock on the tempdb database until the query completes, and cause concurrency issues.
You can do this by running a create table statement before your EXECUTE:
create #bolo ( col1 int not null, col1 int not null )
set @sql = 'INSERT INTO #bolo (col1,col2) '+ 'SELECT * FROM ['+ @lcTableListBeforeLast+']'
CODO ERGO SUM
Edited by - Michael Valentine Jones on 08/26/2005 14:28:59