Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 504493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:30:09+00:00 2026-05-13T06:30:09+00:00

when I need the columns of an existing table I use the query: SELECT

  • 0

when I need the columns of an existing table I use the query:

SELECT c.[name]
FROM
    (SELECT * from syscolumns) c
        INNER JOIN
    (SELECT [id] from sysobjects where name= 'tableName') o on c.[id]=o.[id]

I need the fields of a table that I create during runTime:

select    
    a.ID,
    b.lName,
    b.fName
into #T
from 
    a
        inner join
    b on a.id=b.id

.

select * from #T_columns

will result a table with 3 rows:
id
lName
fName

How can I do it?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:30:09+00:00Added an answer on May 13, 2026 at 6:30 am

    When you create a temp table, it will be in tempdb. You can look it up like this:

    SELECT COLUMN_NAME
    FROM tempdb.INFORMATION_SCHEMA.COLUMNS 
    WHERE TABLE_NAME LIKE '#T|_%' ESCAPE '|'
    

    If you do a SELECT * FROM INFORMATION_SCHEMA.TABLES in tempdb, you’ll see the temp table name you use (#T) actually has a number of underscores appended to it followed by a unique identifier. So you won’t find it it you just search where table_name = ‘#T’.

    So that’s why you have to use a LIKE as I’ve shown above. This will match on “#T_” followed by any other other characters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need the syantax for inserting new column in existing table client.query('ALTER TABLE login
I need to select all columns from two tables, but need to be able
I need to add a NOT NULL column to an existing (populated) table that
I'm doing an insert query where most of many columns would need to be
I need to find the columns in a specific table, which is no problem:
I need to add a column to an existing table in my live sql
I have a MySQL insert statement that inserts data from an existing Despgoods table
I want to left join two tables. My problem is that the table from
How do I use the information from existing MySQL tables to populate a new
I need to save some data to an existing table. So i have column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.