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. Traversing Column rows

Traversing Column rows

Scheduled Pinned Locked Moved Database
questiondatabasehelptutorial
4 Posts 2 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.
  • J Offline
    J Offline
    jonhbt
    wrote on last edited by
    #1

    Hi, I am Writing an sql that returns a single record which is row from a table. In the same sql i would like to traverse through the columns of this row. How can I do that? Is it possible to access the columns in SQL through indexing for example like column[1]? Thanks for your time and help

    M 1 Reply Last reply
    0
    • J jonhbt

      Hi, I am Writing an sql that returns a single record which is row from a table. In the same sql i would like to traverse through the columns of this row. How can I do that? Is it possible to access the columns in SQL through indexing for example like column[1]? Thanks for your time and help

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      You cannot refer to a column by it's ordinal (1) in SQL unless you use dynamic SQL in which case you look up the column name from the schema view and build a string to execute.

      Never underestimate the power of human stupidity RAH

      J 1 Reply Last reply
      0
      • M Mycroft Holmes

        You cannot refer to a column by it's ordinal (1) in SQL unless you use dynamic SQL in which case you look up the column name from the schema view and build a string to execute.

        Never underestimate the power of human stupidity RAH

        J Offline
        J Offline
        jonhbt
        wrote on last edited by
        #3

        thanks for your reply. I am using Dynamic Sql but the problem is that I don't know the name of the column to fetch for, thats why I was trying to find a way similar to indexing.Is there a way?

        M 1 Reply Last reply
        0
        • J jonhbt

          thanks for your reply. I am using Dynamic Sql but the problem is that I don't know the name of the column to fetch for, thats why I was trying to find a way similar to indexing.Is there a way?

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Take a look into the information schema views (under system views in Management Studio) INFORMATION_SCHEMA.COLUMNS is the one you want

          Never underestimate the power of human stupidity RAH

          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