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. Where is my table created...

Where is my table created...

Scheduled Pinned Locked Moved Database
questiondatabasesql-serversysadmintools
8 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.
  • J Offline
    J Offline
    Jun Du
    wrote on last edited by
    #1

    I have a couple of newbie questions for SQL Server. On the SQL Server Management Studio, I used the following script to delete and create a table on the master databse:

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PARTNOTE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[PARTNOTE]
    GO

    CREATE TABLE [dbo].[PARTNOTE] (
    [NUMBER] [nvarchar] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    [NOTE_NUM] [float] NULL ,
    [NOTE] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

    I can run this as many times as I want. Both deletion and creation work well. My first question is "After the creation, where is the table creates?" I couldn't find where the table object from Object Explorer. Now I modify the script to perform the same tasks not on the master, but on "MyDatabase":

    if exists (select * from MyDatabase.dbo.sysobjects where id = object_id(N'[MyDatabase].[dbo].[PARTNOTE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [MyDatabase].[dbo].[PARTNOTE]
    GO

    CREATE TABLE [MyDatabase].[dbo].[PARTNOTE] (
    [NUMBER] [nvarchar] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    [NOTE_NUM] [float] NULL ,
    [NOTE] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

    The creation still works but the deletion does not. It couldn't find where the table was creates. Could someone please explain what goes wrong in the modified script? Thanks!

    Best, Jun

    B S J 3 Replies Last reply
    0
    • J Jun Du

      I have a couple of newbie questions for SQL Server. On the SQL Server Management Studio, I used the following script to delete and create a table on the master databse:

      if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PARTNOTE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[PARTNOTE]
      GO

      CREATE TABLE [dbo].[PARTNOTE] (
      [NUMBER] [nvarchar] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      [NOTE_NUM] [float] NULL ,
      [NOTE] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
      ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

      I can run this as many times as I want. Both deletion and creation work well. My first question is "After the creation, where is the table creates?" I couldn't find where the table object from Object Explorer. Now I modify the script to perform the same tasks not on the master, but on "MyDatabase":

      if exists (select * from MyDatabase.dbo.sysobjects where id = object_id(N'[MyDatabase].[dbo].[PARTNOTE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [MyDatabase].[dbo].[PARTNOTE]
      GO

      CREATE TABLE [MyDatabase].[dbo].[PARTNOTE] (
      [NUMBER] [nvarchar] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
      [NOTE_NUM] [float] NULL ,
      [NOTE] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
      ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

      The creation still works but the deletion does not. It couldn't find where the table was creates. Could someone please explain what goes wrong in the modified script? Thanks!

      Best, Jun

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      After you execute script, refresh Tables node by right click on it and click refresh, it should shows created tables.


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com

      J 2 Replies Last reply
      0
      • B Blue_Boy

        After you execute script, refresh Tables node by right click on it and click refresh, it should shows created tables.


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com

        J Offline
        J Offline
        Jun Du
        wrote on last edited by
        #3

        Thanks. The table created shows up after the refreshing. Another question. My modified script

        if exists (select * from MyDatabase.dbo.sysobjects where id = object_id(N'[MyDatabase].[dbo].[WL_HEADU]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
        drop table [MyDatabase].[dbo].[WL_HEADU]
        GO

        cannot detect the existence of the table I created. If I just execute

        drop table [MyDatabase].[dbo].[WL_HEADU]
        GO

        it works well. What is a proper query I should make in order to detect the table created in "MyDatabase"?

        Best, Jun

        C 1 Reply Last reply
        0
        • B Blue_Boy

          After you execute script, refresh Tables node by right click on it and click refresh, it should shows created tables.


          I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com

          J Offline
          J Offline
          Jun Du
          wrote on last edited by
          #4

          Figured it out...adding

          USE [MyDatabase]
          GO

          before the query can detect the table created.

          Best, Jun

          B 1 Reply Last reply
          0
          • J Jun Du

            Thanks. The table created shows up after the refreshing. Another question. My modified script

            if exists (select * from MyDatabase.dbo.sysobjects where id = object_id(N'[MyDatabase].[dbo].[WL_HEADU]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
            drop table [MyDatabase].[dbo].[WL_HEADU]
            GO

            cannot detect the existence of the table I created. If I just execute

            drop table [MyDatabase].[dbo].[WL_HEADU]
            GO

            it works well. What is a proper query I should make in order to detect the table created in "MyDatabase"?

            Best, Jun

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

            Look to the if statement. Check what

            select * from MyDatabase.dbo.sysobjects where id = object_id(N'[MyDatabase].[dbo].[WL_HEADU]') and OBJECTPROPERTY(id, N'IsUserTable') = 1

            gives you when the file is known to exist. I have 2008 and it uses sys.object and I do not remember how to check for exists from prior.

            1 Reply Last reply
            0
            • J Jun Du

              I have a couple of newbie questions for SQL Server. On the SQL Server Management Studio, I used the following script to delete and create a table on the master databse:

              if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PARTNOTE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[PARTNOTE]
              GO

              CREATE TABLE [dbo].[PARTNOTE] (
              [NUMBER] [nvarchar] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
              [NOTE_NUM] [float] NULL ,
              [NOTE] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
              ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

              I can run this as many times as I want. Both deletion and creation work well. My first question is "After the creation, where is the table creates?" I couldn't find where the table object from Object Explorer. Now I modify the script to perform the same tasks not on the master, but on "MyDatabase":

              if exists (select * from MyDatabase.dbo.sysobjects where id = object_id(N'[MyDatabase].[dbo].[PARTNOTE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [MyDatabase].[dbo].[PARTNOTE]
              GO

              CREATE TABLE [MyDatabase].[dbo].[PARTNOTE] (
              [NUMBER] [nvarchar] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
              [NOTE_NUM] [float] NULL ,
              [NOTE] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
              ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

              The creation still works but the deletion does not. It couldn't find where the table was creates. Could someone please explain what goes wrong in the modified script? Thanks!

              Best, Jun

              S Offline
              S Offline
              SilimSayo
              wrote on last edited by
              #6

              The table is on the cloud :)

              1 Reply Last reply
              0
              • J Jun Du

                Figured it out...adding

                USE [MyDatabase]
                GO

                before the query can detect the table created.

                Best, Jun

                B Offline
                B Offline
                Blue_Boy
                wrote on last edited by
                #7

                That's great :)


                I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.cacttus.com

                1 Reply Last reply
                0
                • J Jun Du

                  I have a couple of newbie questions for SQL Server. On the SQL Server Management Studio, I used the following script to delete and create a table on the master databse:

                  if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PARTNOTE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[PARTNOTE]
                  GO

                  CREATE TABLE [dbo].[PARTNOTE] (
                  [NUMBER] [nvarchar] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
                  [NOTE_NUM] [float] NULL ,
                  [NOTE] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
                  ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

                  I can run this as many times as I want. Both deletion and creation work well. My first question is "After the creation, where is the table creates?" I couldn't find where the table object from Object Explorer. Now I modify the script to perform the same tasks not on the master, but on "MyDatabase":

                  if exists (select * from MyDatabase.dbo.sysobjects where id = object_id(N'[MyDatabase].[dbo].[PARTNOTE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [MyDatabase].[dbo].[PARTNOTE]
                  GO

                  CREATE TABLE [MyDatabase].[dbo].[PARTNOTE] (
                  [NUMBER] [nvarchar] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
                  [NOTE_NUM] [float] NULL ,
                  [NOTE] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
                  ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

                  The creation still works but the deletion does not. It couldn't find where the table was creates. Could someone please explain what goes wrong in the modified script? Thanks!

                  Best, Jun

                  J Offline
                  J Offline
                  jschell
                  wrote on last edited by
                  #8

                  Jun Du wrote:

                  create a table on the master databse:

                  You need to learn to create your own database and then tables go in that. And once you do delete everything that you created in 'master'.

                  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