If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > sql query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-02-04, 17:53
bosewicht1 bosewicht1 is offline
Registered User
 
Join Date: Sep 2004
Posts: 16
sql query

I have a 250 tables and i want to query for every field that contains values >0 and not null. I then want to take those results and create a new table with 250 rows and two columns and populate it with the table name and populate the second with a Y if it is =0 or null and a N if it isn't. anyone have a idea how to do this recursively, without using the script for each indiv field?

Last edited by bosewicht1; 09-02-04 at 22:45.
Reply With Quote
  #2 (permalink)  
Old 09-02-04, 18:04
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
Iteratively this would be relatively easy, recursively I can't think of any way to do it. Which database engine are you using (DB2, Microsoft, MySQL, Oracle, other)?

-PatP
Reply With Quote
  #3 (permalink)  
Old 09-02-04, 18:08
bosewicht1 bosewicht1 is offline
Registered User
 
Join Date: Sep 2004
Posts: 16
using sql. i thought i started to get pretty close, and am working on it, but figured i would post while i worked on it
Reply With Quote
  #4 (permalink)  
Old 09-03-04, 05:23
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Quote:
Originally Posted by Pat Phelan
Which database engine are you using (DB2, Microsoft, MySQL, Oracle, other)?
Quote:
Originally Posted by bosewicht1
using sql.
Whose SQL: (DB2, Microsoft, MySQL, Oracle, other)?
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #5 (permalink)  
Old 09-03-04, 13:17
bosewicht1 bosewicht1 is offline
Registered User
 
Join Date: Sep 2004
Posts: 16
using microsoft mdb's

Last edited by bosewicht1; 09-03-04 at 15:18.
Reply With Quote
  #6 (permalink)  
Old 09-03-04, 18:42
bosewicht1 bosewicht1 is offline
Registered User
 
Join Date: Sep 2004
Posts: 16
ok, so here's where i am.

INSERT INTO Table2 (FIELD1)
SELECT *
FROM TABLE1:

which should insert all fields into the field FIELD1 in TABLE2 ???

then i need to write a script that will loop through each field
name and adds:

INSERT INTO Table2 (FIELD2)
([Field Name] = 0) Or ([Field Name] IS NULL)
to a string, and then run a query on
"SELECT count(*) FROM Table1 WHERE " + [the constructed string]

any ideas?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On