Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 last row data?

Author  Topic 

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-06-24 : 00:21:52
how can i get specific column of last row.
eg.last customerid of table customer

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-24 : 00:58:46
SELECT reqdcol
FROM Table
WHERE PK=(SELECT MAX(PK) FROM Table)


PK is the primary key
Go to Top of Page

kwikwisi
Constraint Violating Yak Guru

283 Posts

Posted - 2008-06-24 : 01:52:30
Pk means primary key,right?
i want last column field(which is pk)

quote:
Originally posted by visakh16

SELECT reqdcol
FROM Table
WHERE PK=(SELECT MAX(PK) FROM Table)


PK is the primary key

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-24 : 02:02:58
quote:
Originally posted by kwikwisi

Pk means primary key,right?
i want last column field(which is pk)

quote:
Originally posted by visakh16

SELECT reqdcol
FROM Table
WHERE PK=(SELECT MAX(PK) FROM Table)


PK is the primary key


then simply use

SELECT max(pk) from table

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-24 : 09:21:45
quote:
Originally posted by kwikwisi

how can i get specific column of last row.
eg.last customerid of table customer


There is no last or first row until you specify what it is

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-25 : 01:47:31
quote:
Originally posted by madhivanan

quote:
Originally posted by kwikwisi

how can i get specific column of last row.
eg.last customerid of table customer


There is no last or first row until you specify what it is

Madhivanan

Failing to plan is Planning to fail


I think he meant last inserted customer id
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-25 : 09:57:15
quote:
Originally posted by visakh16

quote:
Originally posted by madhivanan

quote:
Originally posted by kwikwisi

how can i get specific column of last row.
eg.last customerid of table customer


There is no last or first row until you specify what it is

Madhivanan

Failing to plan is Planning to fail


I think he meant last inserted customer id


There is no way to identify this if the values are not sequential

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-25 : 13:24:43
quote:
Originally posted by madhivanan

quote:
Originally posted by visakh16

quote:
Originally posted by madhivanan

quote:
Originally posted by kwikwisi

how can i get specific column of last row.
eg.last customerid of table customer


There is no last or first row until you specify what it is

Madhivanan

Failing to plan is Planning to fail


I think he meant last inserted customer id


There is no way to identify this if the values are not sequential

Madhivanan

Failing to plan is Planning to fail


what if customerid is an identity column and pk of customer table
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-06-25 : 13:36:30
<<
what if customerid is an identity column and pk of customer table
>>

Then no problem

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -