These are very simple and interesting SQL interview questions , many gets confused while answering it. Try thinking the answer yourself without executing the queries or seeing the answer below.
IF 1 = 0 BEGIN DECLARE @var VARCHAR(100) SET @var = 'www.sqlindia.com' END SELECT @var
IF 1 = 2 BEGIN DECLARE @table TABLE (id int, name varchar(100)) INSERT INTO @table (id, name) VALUES (1, 'www.sqlindia.com') END SELECT * FROM @table
IF 1 = 3 BEGIN CREATE TABLE #table (id int, name varchar(100)) INSERT INTO #table (id, name) VALUES (1, 'www.sqlindia.com') END SELECT * FROM #table
Question 01: NULL
Question 02: An empty table
Question 03: Error Invalid object name
Share your thoughts on this in comment section below, why the Q1 and Q2 did not give any error like Q3?