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. Use stored procedure to check if database exist

Use stored procedure to check if database exist

Scheduled Pinned Locked Moved Database
databasecsharpquestion
4 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.
  • K Offline
    K Offline
    kani98
    wrote on last edited by
    #1

    Is there a stored procedure that I can use to check if a database exist before I create it using C#?

    P 1 Reply Last reply
    0
    • K kani98

      Is there a stored procedure that I can use to check if a database exist before I create it using C#?

      P Offline
      P Offline
      Private_Void
      wrote on last edited by
      #2

      If you are using SQL Server 2005 you can write a proc to use select * from sys.databases.

      K 1 Reply Last reply
      0
      • P Private_Void

        If you are using SQL Server 2005 you can write a proc to use select * from sys.databases.

        K Offline
        K Offline
        kani98
        wrote on last edited by
        #3

        I am using SQL Server 2005 Express, is there something similar that I can use to check if a table exists in the database? Thanks.

        P 1 Reply Last reply
        0
        • K kani98

          I am using SQL Server 2005 Express, is there something similar that I can use to check if a table exists in the database? Thanks.

          P Offline
          P Offline
          Private_Void
          wrote on last edited by
          #4

          This will return all of the tables from the db the query is running under... select * from sysobjects where xtype = 'u'

          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