Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SELECT from multiple tables in a DB

SELECT from multiple tables in a DB

Scheduled Pinned Locked Moved Database
databasesql-serversysadminquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Robby
    wrote on last edited by
    #1

    Is there a way to SELECT from all tables of a specific "Type" in SQL Server 2000? For instance, I have abotu 50 tables that are of "User" type that I want to query, and I am not sure of the most efficient way. If it helps, this is the information I am wanting from ALL tables because they all contain these columns: SELECT submitDate, requestorLastName, requestorFirstName, urlToForm, nof, status FROM WHERE status = 'OPEN' Can someone tell me the best way? Thanks...Robby

    N 1 Reply Last reply
    0
    • R Robby

      Is there a way to SELECT from all tables of a specific "Type" in SQL Server 2000? For instance, I have abotu 50 tables that are of "User" type that I want to query, and I am not sure of the most efficient way. If it helps, this is the information I am wanting from ALL tables because they all contain these columns: SELECT submitDate, requestorLastName, requestorFirstName, urlToForm, nof, status FROM WHERE status = 'OPEN' Can someone tell me the best way? Thanks...Robby

      N Offline
      N Offline
      notadood
      wrote on last edited by
      #2

      You can start with this: sp_MSforeachtable 'select * from ?' and then customize the select with whatever you want.

      R 1 Reply Last reply
      0
      • N notadood

        You can start with this: sp_MSforeachtable 'select * from ?' and then customize the select with whatever you want.

        R Offline
        R Offline
        Robby
        wrote on last edited by
        #3

        This is a great command. I can't seem to get it to do what I want. I have the command, but it seems to be just "picking" a table out of the database and displaying the properties. I am attempting to display this information in an HTML table. Here's the code: sqlstr="sp_MSforeachtable 'select submitDate, requestorLastName, requestorFirstName, urlToForm, nof, status from ?'" Set results = MyConn.Execute(sqlstr) submitDate=results("submitDate") requestorLastName=results("requestorLastName") and so forth for each column... I have approx 50 tables, and my html output only displays entries for only one of the tables...what do I need to do to be able to query all and display all for whatever table matches the query? Thanks

        D 1 Reply Last reply
        0
        • R Robby

          This is a great command. I can't seem to get it to do what I want. I have the command, but it seems to be just "picking" a table out of the database and displaying the properties. I am attempting to display this information in an HTML table. Here's the code: sqlstr="sp_MSforeachtable 'select submitDate, requestorLastName, requestorFirstName, urlToForm, nof, status from ?'" Set results = MyConn.Execute(sqlstr) submitDate=results("submitDate") requestorLastName=results("requestorLastName") and so forth for each column... I have approx 50 tables, and my html output only displays entries for only one of the tables...what do I need to do to be able to query all and display all for whatever table matches the query? Thanks

          D Offline
          D Offline
          Daniel Turini
          wrote on last edited by
          #4

          This is because you're getting multiple recordsets. When you reach the end of the first recordset, use the NextRecordset method of the recordset to get the next table. Concussus surgo. When struck I rise.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups