C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

getting value of identity columns next value before inserting


Posted Date: 28 Apr 2007      Posted By: Manisha      Member Level: Silver     Points: 2   Responses: 2



hi friends

i am using sql server 2000

in a table i have identity column with seed value


i want to find the next value which will be given to new row
before actaully inserting row

i use select max

but if there is no any current row
then i am getting problem

how can i solve this


thanks





Responses

Author: sree    28 Apr 2007Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

SELECT MAX(identity) from Table WHERE identity NOT IN ( SELECT TOP 2 identity FROM Table ORDER BY identity DESC )
this command gives u the second max identity no



Author: Vadivel Mohanakrishnan    28 Apr 2007Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Make use of IsNull() function to return 0 when there is no record. More over you need to show us the query what you have written to understand your question better!

Best Regards
Vadivel

MVP SQL Server
http://vadivel.blogspot.com



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : please ver urgent
Previous : please very very..................... urgent
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use