Would a table variable fit your needs... I prefer these because of these scoping issues.
DECLARE @TempTable TABLE (
-- Your definition
)
IF @someVariable = 0
BEGIN
INSERT INTO @TempTable (...)
SELECT ...
FROM MyTable
WHERE Category="Something"
END
ELSE
BEGIN
INSERT INTO @TempTable (...)
SELECT ...
FROM MyTable
WHERE Category="SomethingElse"
END
Or are you trying to prevent having to explicitly define the columns? Can you refactor to determine the condition beforehand:
DECLARE @Category varchar(100)
IF @someVariable = 0
BEGIN
SET @Category = "Something"
END
ELSE
BEGIN
SET @Category = "SomethingElse"
END
SELECT *
INTO #TempTable
FROM MyTable
WHERE Category = @Category
DROP TABLE #TempTable