Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

HOW TO GET THE VALUE OF SQL TABLE ROW INDEX Expand / Collapse
Author
Message
Posted Tuesday, December 18, 2012 7:56 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, July 12, 2013 7:25 AM
Points: 39, Visits: 144
How can you get the value of a table COLUMN INDEX.
Post #1398114
Posted Wednesday, December 19, 2012 12:20 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 12:11 PM
Points: 42,470, Visits: 35,541
Could you be more specific about what you're trying to do?


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
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

Post #1398212
Posted Thursday, December 20, 2012 7:19 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 9:39 AM
Points: 156, Visits: 458
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
Post #1398963
Posted Thursday, December 20, 2012 11:09 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, July 12, 2013 7:25 AM
Points: 39, 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
Post #1399202
Posted Friday, December 21, 2012 12:40 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 12:11 PM
Points: 42,470, Visits: 35,541
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 2008, MVP
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

Post #1399228
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse