Article ID: 166200
Article Last Modified on 10/17/2003
At the second execution:
At the third execution:
DROP PROCEDURE sp_test
GO
CREATE PROCEDURE sp_test
AS
EXEC ("IF EXISTS (SELECT * FROM tempdb..sysobjects
WHERE name = '##testTable' AND type = 'u')
DROP TABLE ##testTable")
CREATE TABLE ##testTable (col INT)
INSERT INTO ##testTable SELECT 1
cleanup:
EXEC ("IF EXISTS (SELECT * FROM tempdb..sysobjects
WHERE name = '##testTable' AND type = 'u') DROP TABLE ##testTable")
GO
EXEC sp_test /* First execution */
This command did not return data, and it did not return any rows.
EXEC sp_test /* Second execution */
EXEC sp_test /* Third execution */
CREATE PROCEDURE sp_test WITH RECOMPILE
AS
EXEC ("IF EXISTS (SELECT * FROM tempdb..sysobjects
WHERE name = '##testTable' AND type = 'u')
DROP TABLE ##testTable")
CREATE TABLE ##testTable (col INT)
EXEC ('INSERT INTO ##testTable SELECT 1')
cleanup:
EXEC ("IF EXISTS (SELECT * FROM tempdb..sysobjects
WHERE name = '##testTable' AND type = 'u') DROP TABLE ##testTable")
GO
Keywords: kbbug kbpending kbusage KB166200