SunQuest
           Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

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 Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old June 18th, 2003, 11:53 AM
KenDingo KenDingo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 1 KenDingo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
adding a incremental number

Hello,

I am working on a basic insert of data into a SQL2000 table, I am new to SQL and only know really basic things right now. The table has a number field that is not a identity field but the numbers must be uniqe. How do i use the number of the previous record to create the new number of the record i am inserting.

Here is an example of the insert statement i have already:
insert into T_eaddress
(
eaddress_no, "This is the field that will hold the number"
customer_no,
eaddress_type,
address,
start_dt,
primary_ind,
inactive,
market_ind,
create_dt,
html_ind
)

select
"this is where i need the function"
epatron_pactpatronnum,
'3',
epatron_email,
epatron_bademaildate,
'n',
epatron_activee,
'y',
getdate(),
'y'

from e_patron inner join
t_eaddress on e_patron.epatron_pactpatronnum =
t_eaddress.customer_no


Any insight would be great.
Thanks

Reply With Quote
  #2  
Old June 21st, 2003, 11:59 PM
fractalvibes fractalvibes is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Location: Waco, Texas
Posts: 632 fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 14 h 11 m 13 sec
Reputation Power: 22
Why not define that number as an identity field? If you cannot do that, consider making the field a timestamp value.

Phil J.
__________________
...because that is the way we have always done it. We've been doing it like that for 80 Years! (How do we change that mindset?)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > adding a incremental number


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