MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

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:
  #1  
Old July 12th, 2004, 02:34 PM
doctor doctor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 41 doctor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
populating a table with the results of a SQL query

Is there any way i could take the first 50 results of a sql query and store them into 1 table in access and take the next 50 and store them into a second table in access? Is there any SQL statement that will direct where the output gets directed
to?

OR is there a way to have the sql reults paird up with a autonumbered ID?

Doc

Reply With Quote
  #2  
Old July 12th, 2004, 05:28 PM
Nisus Nisus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 2 Nisus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Top 50

Does your primary table have a Primary Key that is autonumbered? If so then you can use a between statement for your select.


Code:
INSERT INTO t_myoutput_table1 (id,firstname,lastname)
VALUES(SELECT id,firstname,lastname FROM t_mytable WHERE id BETWEEN 1 AND 50)


or


Code:
INSERT INTO t_myoutput_table2 (id,firstname,lastname)
VALUES(SELECT id,firstname,lastname FROM t_mytable WHERE id BETWEEN 51 AND 100)


-Travis

Reply With Quote
  #3  
Old July 13th, 2004, 10:22 AM
doctor doctor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 41 doctor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Ok A bit confused, As of now I have 1 query that returns 100+ results. I have 2 auto numbered tables ready to accept data Table1, Table2. How do you implement the code you provided to get my data from the query to the 2 tables? And what is mytable? If you are assuming that i have 1 big auto numbered table with all the query results in it, Im not that far yet, if you know how to get to that step please let me know!



Thx

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > populating a table with the results of a SQL query


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 6 hosted by Hostway