T-SQL error object exists when separated in if/else blocks
- by Jeff O
I get the error: Msg 2714, Level 16, State 1, Line 16
There is already an object named '#mytemptable' in the database.
There are ways around it, but wonder why this happens. Seems like SQL Server is verifying both blocks of the if/else statement?
declare @choice int
select @choice = 1
if @choice = 1
begin
select 'MyValue = 1' AS Pick…