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. List user tables in a database??

List user tables in a database??

Scheduled Pinned Locked Moved Database
databasequestionsharepointsql-servervisual-studio
7 Posts 5 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.
  • M Offline
    M Offline
    Martin Haesemeyer
    wrote on last edited by
    #1

    Hello! How is it possible to list all objects(tables, views) in a database that have been created by the databases designer and NOT by SQL server? I know that EXECUTE sp_databases @table_type="'TABLE'" shoudn't list any system tables. But if I execute this statement on a database I created, I always get tables I didn't create :mad: and which the Server Explorer of VS doesn't show? So how can I get a list of only the tables (it's the same for the views) that I created?? :confused: Cheers TIA Martin "Situation normal - all fu***d up" Illuminatus!

    M T N R 4 Replies Last reply
    0
    • M Martin Haesemeyer

      Hello! How is it possible to list all objects(tables, views) in a database that have been created by the databases designer and NOT by SQL server? I know that EXECUTE sp_databases @table_type="'TABLE'" shoudn't list any system tables. But if I execute this statement on a database I created, I always get tables I didn't create :mad: and which the Server Explorer of VS doesn't show? So how can I get a list of only the tables (it's the same for the views) that I created?? :confused: Cheers TIA Martin "Situation normal - all fu***d up" Illuminatus!

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      exec sp_tables NULL,dbo,dbname,"'TABLE'" exec sp_tables NULL,dbo,dbname,"'VIEW'" Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down

      M 1 Reply Last reply
      0
      • M Martin Haesemeyer

        Hello! How is it possible to list all objects(tables, views) in a database that have been created by the databases designer and NOT by SQL server? I know that EXECUTE sp_databases @table_type="'TABLE'" shoudn't list any system tables. But if I execute this statement on a database I created, I always get tables I didn't create :mad: and which the Server Explorer of VS doesn't show? So how can I get a list of only the tables (it's the same for the views) that I created?? :confused: Cheers TIA Martin "Situation normal - all fu***d up" Illuminatus!

        T Offline
        T Offline
        TigerNinja_
        wrote on last edited by
        #3

        Martin Häsemeyer wrote: How is it possible to list all objects(tables, views) in a database that have been created by the databases designer and NOT by SQL server? to list all user tables select * from sysobjects where type='U' to list all views (may not all be user though) select * from sysobjects where type='V'


        Soliant | email   "The whole of science is nothing more than a refinement of everyday thinking." -Albert E.

        M 1 Reply Last reply
        0
        • M Mazdak

          exec sp_tables NULL,dbo,dbname,"'TABLE'" exec sp_tables NULL,dbo,dbname,"'VIEW'" Mazy **"If I go crazy then will you still Call me Superman If I’m alive and well, will you be There holding my hand I’ll keep you by my side with My superhuman might Kryptonite"**Kryptonite-3 Doors Down

          M Offline
          M Offline
          Martin Haesemeyer
          wrote on last edited by
          #4

          Unfortunately that's exactly the same as exec sp_tables @table_type="'TABLE'" :( I get my user tables and a table called dtproperties... But Server Explorer can sort it out :confused: But thanks anyway :) Cheers Martin "Situation normal - all fu***d up" Illuminatus!

          1 Reply Last reply
          0
          • T TigerNinja_

            Martin Häsemeyer wrote: How is it possible to list all objects(tables, views) in a database that have been created by the databases designer and NOT by SQL server? to list all user tables select * from sysobjects where type='U' to list all views (may not all be user though) select * from sysobjects where type='V'


            Soliant | email   "The whole of science is nothing more than a refinement of everyday thinking." -Albert E.

            M Offline
            M Offline
            Martin Haesemeyer
            wrote on last edited by
            #5

            This method seems to produce exactly the same results but with additional information... :( Maybe I'll have to manually exclude the additional sysobjects and hope that their names are always the same. Cheers and thanks for the reply Martin "Situation normal - all fu***d up" Illuminatus!

            1 Reply Last reply
            0
            • M Martin Haesemeyer

              Hello! How is it possible to list all objects(tables, views) in a database that have been created by the databases designer and NOT by SQL server? I know that EXECUTE sp_databases @table_type="'TABLE'" shoudn't list any system tables. But if I execute this statement on a database I created, I always get tables I didn't create :mad: and which the Server Explorer of VS doesn't show? So how can I get a list of only the tables (it's the same for the views) that I created?? :confused: Cheers TIA Martin "Situation normal - all fu***d up" Illuminatus!

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

              Try selecting it from the INFORMATION_SCHEMA views directly. SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME <> 'dtproperties' AND TABLE_TYPE = 'BASE TABLE' ORDER BY 1

              1 Reply Last reply
              0
              • M Martin Haesemeyer

                Hello! How is it possible to list all objects(tables, views) in a database that have been created by the databases designer and NOT by SQL server? I know that EXECUTE sp_databases @table_type="'TABLE'" shoudn't list any system tables. But if I execute this statement on a database I created, I always get tables I didn't create :mad: and which the Server Explorer of VS doesn't show? So how can I get a list of only the tables (it's the same for the views) that I created?? :confused: Cheers TIA Martin "Situation normal - all fu***d up" Illuminatus!

                R Offline
                R Offline
                Rein Hillmann
                wrote on last edited by
                #7

                Try this (I'm not at a SQL box at the moment so it might not work 100%) SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE OBJECTPROPERTY(OBJECT_ID(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)), 'IsMSShipped') = 0 AND TABLE_TYPE = 'BASE TABLE'

                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