How can we help you today? How can we help you today?

Expand * doesn't pickup all the columns from a Temp Table

If you have something like this:

SELECT
          [a].Field1,
          [a].Field2,
          [b].AnotherField1,
          [b].AnotherField2
INTO
          #TempTable
FROM
          TableA
          LEFT OUTER JOIN TableB ON TableA.Field1 = TableB.AnotherField1

Then you add:

SELECT
         tt.*
FROM 
        #TempTable tt

Then you put your cursor on the * and hit the Tab key you get:

SELECT
          [tt].Field1,
          [tt].Field2
FROM 
        #TempTable tt

None of the fields from Table B show up.
BrienKing
0

Comments

3 comments

  • Sergio R
    Hi Brien,

    I have just tested this scenario on SQL Prompt 9.5.14 (latest), on SSMS 17 and it worked correctly:

    Sergio R
    0
  • Matthew_Sontum
    It's still an issue (I posted about it earlier). If you format (and expand wildcards) :

    WITH CTE1 AS (
    SELECT *, a+b as ab FROM #TempTable), CTE2 AS (
    SELECT *, c+d as cd FROM CTE1)
    SELECT * FROM CTE2

    It becomes:

    WITH CTE1 AS (SELECT *, a + b AS ab FROM #TempTable),
    CTE2 AS (SELECT CTE1.ab, c + d AS cd FROM CTE1)
    SELECT CTE2.ab, CTE2.cd FROM CTE2;

    The other * columns from #TempTable aren't returned in the final output
    Matthew_Sontum
    0
  • Sergio R
    For more details regarding @Matthew_Sontum 's issue please see https://forum.red-gate.com/discussion/85743/sql-prompt-incorrectly-expanding
    Sergio R
    0

Add comment

Please sign in to leave a comment.