I have been able to create a data connection from Excel to SQL Server and execute many SQL queries successfully. But I cannot get any TSQL to work if it includes a temporary
I wanted to add to the above answer - just using SET NOCOUNT ON
at the top of the query, with a regular temp table SELECT name INTO #Names FROM Employee
should work.
A table variable is not needed here.
You could also add SET ANSI_WARNINGS OFF
to avoid messages like "NULL Value is eliminated by an aggregate".