SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


HOW TO GET THE VALUE OF SQL TABLE ROW INDEX


HOW TO GET THE VALUE OF SQL TABLE ROW INDEX

Author
Message
lonhanner
lonhanner
SSC-Enthusiastic
SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)

Group: General Forum Members
Points: 149 Visits: 144
How can you get the value of a table COLUMN INDEX.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)

Group: General Forum Members
Points: 210495 Visits: 46249
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


HildaJ
HildaJ
SSC Eights!
SSC Eights! (985 reputation)SSC Eights! (985 reputation)SSC Eights! (985 reputation)SSC Eights! (985 reputation)SSC Eights! (985 reputation)SSC Eights! (985 reputation)SSC Eights! (985 reputation)SSC Eights! (985 reputation)

Group: General Forum Members
Points: 985 Visits: 571
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
lonhanner
lonhanner
SSC-Enthusiastic
SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)SSC-Enthusiastic (149 reputation)

Group: General Forum Members
Points: 149 Visits: 144
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
GilaMonster
GilaMonster
SSC Guru
SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)

Group: General Forum Members
Points: 210495 Visits: 46249
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


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search