Well this seem to work fine (which is what I think you're doing)...
BUT there GOT to be a better way than building a destroying onjects on the fly..gonna keep the catalog real busy.
Is all of the table structure always the same? or do they vary?
This should help with the object checking...
USE Northwind
GO
CREATE TABLE myTable99 (col1 int)
GO
CREATE PROC mySproc99
@tbname sysname
AS
DECLARE @sql varchar(8000), @rc int
SELECT @sql = 'select 1 from sysobjects where id = object_id('+''''+@tbname+''''+') and sysstat & 0xf = 3'
EXEC(@sql)
SELECT @rc = @@ROWCOUNT
SELECT 'ROWS: ' + Convert(varchar(3),@rc)
IF @rc <> 0
BEGIN
SELECT @sql = 'DROP TABLE '+ @tbname
EXEC(@sql)
SELECT @@Error
END
SELECT @sql = 'SELECT 1 AS Col1 INTO ' + @tbname
EXEC (@sql)
SELECT @@Error
SELECT @sql = 'SELECT * FROM ' + @tbname
EXEC (@sql)
SELECT @@Error
GO
EXEC mySproc99 'myTable99'
GO
DROP TABLE myTable99
GO
DROP PROC mySproc99
GO
Brett
8-)