I am creating a temp table inside a store proc. Depending on whether an input
parameter was passed, I run different code to create the temp table.
The SQL compiler gives me this error when I try to run the code:
There is already an object named #SelectedCustomers in the database.
What am I doing wrong here?
(This is a simplification of what I'm really working with)
-- @tcState is an input parameter to the stored proc, and is in scope.
IF @tcState IS NOT NULL BEGIN
SELECT kCustomer
INTO #SelectedCustomers
FROM Customers
WHERE cState = @tcState
END
ELSE BEGIN
SELECT kCustomer
INTO #SelectedCustomers
FROM Customers
END
"Problems cannot be solved at the same level of awareness that created them." - Albert Einstein
Bruce Allen
NTX Data