HOW TO GET THE VALUE OF SQL TABLE ROW INDEX

  • How can you get the value of a table COLUMN INDEX.

  • Could you be more specific about what you're trying to do?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Are you trying to do something like this?

    Select ROW_NUMBER() OVER(ORDER BY FirstName, LastName) AS RowNumber, FirstName, LastName

    Output

    RowNumber FirstName LastName

    1 Joe Smith

    2 Joe Thomas

    3 Joe Williams

  • I am trying to write a Master/detail code and can't get off to a start on it. I have been working on this this for over a week now. I have already written all the code thats Add,Update,Delete for forms for other areas of this program and all that works well.

    I am trying to get the data out of each column of all the rows in a datagridview and add it to a lists, and then loop through the list pulling out the column data for each row if i can get this I know how to get it in the database. This is a 3 layer program, and I am using Class Objects. For example I have class (Trips which stores the code for the objects in this table, I have a Class called TripsDB which is dose all the database work.

    Any Takers

    Thanks so much

  • Why looping? SQL doesn't need any form of looping to get master-detail information. You'd write a single query with a join across the two tables. Something like this:

    SELECT Master.Col1, Master.Col2, Detail.Col1, Detail.Col2, /*more columns*/ FROM Master INNER JOIN Detail on Master.PrimaryKeyColumn = Detail.MasterPrimaryKey

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply