Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old March 5th, 2004, 09:30 AM
krstofer's Avatar
krstofer krstofer is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: NJ
Posts: 60 krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level)krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level)krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level)krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level)krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level)krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 12 h 50 m 52 sec
Reputation Power: 27
Send a message via AIM to krstofer
auto increment

Hi,

I am inserting records into SQL db using ASP VBScript. I want to take the id number if the last reccord add 1 to it and insert the new record with the new id number.

if someone can tell me just how to query only the last record, I can figure out the rest.

Thanks,
Krs

Reply With Quote
  #2  
Old March 5th, 2004, 09:45 AM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
Easiest way to do it would be to make the ID field an Identity data type, similar to Access Autonumber. It will automatically increment when a new record is added.

Reply With Quote
  #3  
Old March 24th, 2004, 10:53 AM
krstofer's Avatar
krstofer krstofer is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: NJ
Posts: 60 krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level)krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level)krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level)krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level)krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level)krstofer User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 12 h 50 m 52 sec
Reputation Power: 27
Send a message via AIM to krstofer
Quote:
Originally Posted by Memnoch
Easiest way to do it would be to make the ID field an Identity data type, similar to Access Autonumber. It will automatically increment when a new record is added.

Thanks,
What I ended up doing is querying the DB with the MAX(id) as ID and adding 1 to the field to create the next number. I am creating the DB through the web since I do not have access to the machine the DB is actually on. This is a very new experience to me so I am having some trouble, but getting through it.

BTW, love the name. It was my email name in College. I am in the middle of reading merrick now.

Krs

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > auto increment


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT