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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Find tables used in stored procedures

Find tables used in stored procedures

Scheduled Pinned Locked Moved Database
databasetools
5 Posts 2 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.
  • C Offline
    C Offline
    Corporal Agarn
    wrote on last edited by
    #1

    Hello, I am looking for a way to find what tables are used within a stored procedure. I have around 300 stored procedures that I would like to know what if any tables are used. I can script the stored procedures to a file that can be investigated. Thank you for any leads djj

    L 1 Reply Last reply
    0
    • C Corporal Agarn

      Hello, I am looking for a way to find what tables are used within a stored procedure. I have around 300 stored procedures that I would like to know what if any tables are used. I can script the stored procedures to a file that can be investigated. Thank you for any leads djj

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      djj55 wrote:

      I have around 300 stored procedures that I would like to know what if any tables are used.

      If it's Sql2005, then you could use the sp_depends[^] procedure to list all the dependencies. It's replaced in Sql2008 with something new, but it would probably still work. Hope this helps :)

      I are Troll :suss:

      C 1 Reply Last reply
      0
      • L Lost User

        djj55 wrote:

        I have around 300 stored procedures that I would like to know what if any tables are used.

        If it's Sql2005, then you could use the sp_depends[^] procedure to list all the dependencies. It's replaced in Sql2008 with something new, but it would probably still work. Hope this helps :)

        I are Troll :suss:

        C Offline
        C Offline
        Corporal Agarn
        wrote on last edited by
        #3

        Thank you for the reply. As I am currently working with 2000 sp_depends is the ticket. The problem is getting the output into a table. Thank you again, djj

        L 1 Reply Last reply
        0
        • C Corporal Agarn

          Thank you for the reply. As I am currently working with 2000 sp_depends is the ticket. The problem is getting the output into a table. Thank you again, djj

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You're welcome :) There are no 'real' options to get the multiple result-tables into a temptable under Sql 2000 that I'm aware of. In Sql2005, you could try using a CLR sproc. As a hack, perhaps you could execute a DOS-command from SQL? If you can execute isql.exe, then you can pipe the result of the command to a textfile. It would get real messy if you try to parse the resulting textfile using SQL, so it might be easier to execute a small console application that parses it and writes it to the database.

          I are Troll :suss:

          C 1 Reply Last reply
          0
          • L Lost User

            You're welcome :) There are no 'real' options to get the multiple result-tables into a temptable under Sql 2000 that I'm aware of. In Sql2005, you could try using a CLR sproc. As a hack, perhaps you could execute a DOS-command from SQL? If you can execute isql.exe, then you can pipe the result of the command to a textfile. It would get real messy if you try to parse the resulting textfile using SQL, so it might be easier to execute a small console application that parses it and writes it to the database.

            I are Troll :suss:

            C Offline
            C Offline
            Corporal Agarn
            wrote on last edited by
            #5

            Thank you, I will look into the "DOS" solution tomorrow. Sometime in the next three months we are upgrading to 2008.

            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