473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

SQL Server 7.0 equiv of IDENTITY_CURRENT

Hi,
I am writing code for the subject version and am trying to find the
equivalent of

SELECT SaveDate FROM Performance
WHERE IDENTITYCOL = IDENT_CURRENT('Performance')

In other words I need to return a field in the last row of a table. v7.0
does not recognise IDENT_CURRENT

Any offers?

(btw, cannot upgrade - not my database)

Thanks
Aug 4 '06 #1
2 3012
Jack Turnbull wrote:
Hi,
I am writing code for the subject version and am trying to find the
equivalent of

SELECT SaveDate FROM Performance
WHERE IDENTITYCOL = IDENT_CURRENT('Performance')

In other words I need to return a field in the last row of a table. v7.0
does not recognise IDENT_CURRENT

Any offers?

(btw, cannot upgrade - not my database)

Thanks
DBCC CHECKIDENT ('tablename', NORESEED) will give you the same value as
IDENT_CURRENT() but that won't necessarily be the last value inserted
in the current connection and it may not even be a value that exists in
the table. Those same caveats apply to IDENT_CURRENT(). IDENT_CURRENT()
is of very little use at all IMO but it is often MIS-used.

Porbably the better alternatives are:

SELECT TOP 1 SaveDate
FROM Performance
ORDER BY identitycol DESC;

SELECT SaveDate
FROM Performance
WHERE identitycol = @@IDENTITY;

In SQL Server 2000, use SCOPE_IDENTITY() in preference to @@IDENTITY.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--

Aug 4 '06 #2
Thanks David,
Your first alternative worked great!
Cheers,
Jack
"David Portas" wrote in message
news:11*********************@m79g2000cwm.googlegro ups.com...
Jack Turnbull wrote:
>Hi,
I am writing code for the subject version and am trying to find the
equivalent of

SELECT SaveDate FROM Performance
WHERE IDENTITYCOL = IDENT_CURRENT('Performance')

In other words I need to return a field in the last row of a table. v7.0
does not recognise IDENT_CURRENT

Any offers?

(btw, cannot upgrade - not my database)

Thanks

DBCC CHECKIDENT ('tablename', NORESEED) will give you the same value as
IDENT_CURRENT() but that won't necessarily be the last value inserted
in the current connection and it may not even be a value that exists in
the table. Those same caveats apply to IDENT_CURRENT(). IDENT_CURRENT()
is of very little use at all IMO but it is often MIS-used.

Porbably the better alternatives are:

SELECT TOP 1 SaveDate
FROM Performance
ORDER BY identitycol DESC;

SELECT SaveDate
FROM Performance
WHERE identitycol = @@IDENTITY;

In SQL Server 2000, use SCOPE_IDENTITY() in preference to @@IDENTITY.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--

Aug 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: lawrence | last post by:
How do I get PHP to tell the server that when I echo text to the screen, I need for the text to be sent as UTF-8? How does Apache know the right encoding when all the text is being generated by...
4
by: Martin | last post by:
This is probably more of an HTML question than PHP. Perhaps someone here can answer or point me to a proper newsgroup. How can I force the browser to reload an image from the server? I have a...
8
by: Nige | last post by:
I've got an old web site that comes up before its replacement in Google listings. I've read the document on Google about sending a "301" code from the server:...
1
by: Nick Kew | last post by:
Someone just drew attention to an open bug report in Apache concerning shipping with an AddDefaultCharset set by default in httpd.conf. This leads to bogus charsets being served in many cases. ...
4
by: HeroOfSpielburg | last post by:
Hello, I am trying to using the Shift_JIS character set in my web pages, and have specified it as such in the <head>. <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> ...
10
by: Newry | last post by:
Hi, If you have both this HTTP header: Content-Type: text/html; charset=ISO-8859-1 and this HTML element in the <head>: <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
4
by: Jim Hammond | last post by:
After much effort, it doesn't seem possible to redirect the user to a new page after 10 seconds by using a server-side timer. I am now using the following meta statement to accomplish the same...
2
by: Oberon | last post by:
Why does this not work as it should? I expect index.aspx to show:. Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\inetpub\wwwroot\ChatSimple\db\chatusers.mdb Instead, I get: ...
3
by: graphicssl | last post by:
Okay, so first of all, I'm a designer first and a light coder second (I'm only really trained with HTML and CSS). So I apologize for having to post about something that's probably super-trivial! ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.