Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Getting the columns

Getting the columns

Scheduled Pinned Locked Moved Database
tutorialquestion
10 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M J Jaya Chitra
    wrote on last edited by
    #1

    Can anyone tell me how to retrieve the column names in a table?

    Best Regards, M. J. Jaya Chitra

    G R K S 4 Replies Last reply
    0
    • M M J Jaya Chitra

      Can anyone tell me how to retrieve the column names in a table?

      Best Regards, M. J. Jaya Chitra

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      If you are using sql server then you can use the following query: SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'name_of_the_table'

      #region signature my articles #endregion

      R 1 Reply Last reply
      0
      • G Giorgi Dalakishvili

        If you are using sql server then you can use the following query: SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'name_of_the_table'

        #region signature my articles #endregion

        R Offline
        R Offline
        r a j u u
        wrote on last edited by
        #3

        ist working? i tried this query but its saying Invalid columnname...

        Rajendran

        G J 2 Replies Last reply
        0
        • R r a j u u

          ist working? i tried this query but its saying Invalid columnname...

          Rajendran

          G Offline
          G Offline
          Giorgi Dalakishvili
          wrote on last edited by
          #4

          Yes, it is. Just make sure you are performing the query against the database that contains your table

          #region signature my articles #endregion

          M 1 Reply Last reply
          0
          • M M J Jaya Chitra

            Can anyone tell me how to retrieve the column names in a table?

            Best Regards, M. J. Jaya Chitra

            R Offline
            R Offline
            r a j u u
            wrote on last edited by
            #5

            In SQL, Assume columnname- id(It should be identity and autoincrement),Name then you will try this query select name from tablename where id=0

            Rajendran

            1 Reply Last reply
            0
            • M M J Jaya Chitra

              Can anyone tell me how to retrieve the column names in a table?

              Best Regards, M. J. Jaya Chitra

              K Offline
              K Offline
              Krish KP
              wrote on last edited by
              #6

              In MS SQL Server syscolumns table holds column names and sysobjects table names. SELECT * FROM syscolumns co INNER JOIN sysobjects so ON co.id = so.id WHERE so.name = 'mytable'

              Regards KP

              1 Reply Last reply
              0
              • G Giorgi Dalakishvili

                Yes, it is. Just make sure you are performing the query against the database that contains your table

                #region signature my articles #endregion

                M Offline
                M Offline
                M J Jaya Chitra
                wrote on last edited by
                #7

                Thanks a lot. It is working fine.

                Best Regards, M. J. Jaya Chitra

                G 1 Reply Last reply
                0
                • M M J Jaya Chitra

                  Thanks a lot. It is working fine.

                  Best Regards, M. J. Jaya Chitra

                  G Offline
                  G Offline
                  Giorgi Dalakishvili
                  wrote on last edited by
                  #8

                  You are welcome :)

                  #region signature my articles #endregion

                  1 Reply Last reply
                  0
                  • M M J Jaya Chitra

                    Can anyone tell me how to retrieve the column names in a table?

                    Best Regards, M. J. Jaya Chitra

                    S Offline
                    S Offline
                    Senu Gandhi
                    wrote on last edited by
                    #9

                    Hi Jaya, For a simple solution try this sp_help '' Senthil

                    1 Reply Last reply
                    0
                    • R r a j u u

                      ist working? i tried this query but its saying Invalid columnname...

                      Rajendran

                      J Offline
                      J Offline
                      joemonvarghese
                      wrote on last edited by
                      #10

                      hi try this qry select name from syscolumns where id= (select id from sysobjects where name=)

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups