locked
Test Table Permissions RRS feed

  • Question

  • New to SQL, using (MSSQL 2012).  I created a new database called NewTest and a table dbo.Movies.  I tried to practice deleting the table using:

    USE NewTest

    GO

    DROP dbo.Movies

    I got the error:  "Cannot drop the table 'dbo.Movies' because it does not exist or you do not have permission".

    However, I was actually able to execute and drop the table.  Why was I able to drop despite the error - will that always be the case if I am the owner?

    Thanks!

    Thursday, April 7, 2016 10:47 PM

Answers

  • I needed to refresh the actual database, not just the object explorer.
    • Marked as answer by sobrio32 Friday, April 8, 2016 12:16 AM
    Friday, April 8, 2016 12:16 AM

All replies

  • No, you should not be able to drop the table, if the error was real.  The fact that you are the owner of the database, you should be able to drop the table without any issues.

    I think it must have been an oversight from your end..

    if you want, create the table and drop it again, see if the error happens again

    Drop Table dbo.movies ( you missed table in the syntax above)


    Hope it Helps!!

    Thursday, April 7, 2016 10:58 PM
  • Yeah, I can still create it fresh and drop it again - the table dbo.Movies has a red line under it in the script and the error was when I hovered over it.

    I went back and created the table by right clicking, thinking maybe there were some auto settings I needed, and the table was created fine.  So I have a dbo.Movies table with columns (ID, TITLE, GENRE). However when I enter the following:

    INSERT dbo.Movies(ID, TITLE, GENRE)
    VALUES(2, 'Top Gun', 'Action')
    GO

    I get the (hover over) error "Invalid object name 'Movies'."  But everything compiles and executes fine, and the new row is inserted.  It's just the red line errors I can't figure out.  And the suggestion box doesn't pull up dbo.Movies when I am typing like in the other databases I have been testing out.  It doesn't recognize it.

    Thursday, April 7, 2016 11:25 PM
  • Yeah, I can still create it fresh and drop it again - the table dbo.Movies has a red line under it in the script and the error was when I hovered over it.

    I went back and created the table by right clicking, thinking maybe there were some auto settings I needed, and the table was created fine.  So I have a dbo.Movies table with columns (ID, TITLE, GENRE). However when I enter the following:

    INSERT dbo.Movies(ID, TITLE, GENRE)
    VALUES(2, 'Top Gun', 'Action')
    GO

    I get the (hover over) error "Invalid object name 'Movies'."  But everything compiles and executes fine, and the new row is inserted.  It's just the red line errors I can't figure out.  And the suggestion box doesn't pull up dbo.Movies when I am typing like in the other databases I have been testing out.  It doesn't recognize it.

    I gues you are in the wrong database context.

    try this..

    Use <<yourdatabase>> --replace this with actual database name

    GO

    INSERT dbo.Movies(ID, TITLE, GENRE)
    VALUES(2, 'Top Gun', 'Action')
    GO


    Hope it Helps!!

    Thursday, April 7, 2016 11:28 PM
  • Thursday, April 7, 2016 11:45 PM
  • I closed SQL Server and reopened and everything is fine, there was no issues using the exact same scripting. There must have just been some issue with refreshing, even though I kept clicking refresh on Object Explorer.  If anyone knows why that is let me know.  Thanks for your help Stan210 :-)
    Thursday, April 7, 2016 11:58 PM
  • I needed to refresh the actual database, not just the object explorer.
    • Marked as answer by sobrio32 Friday, April 8, 2016 12:16 AM
    Friday, April 8, 2016 12:16 AM
  • Intellisense is just confused. Ignore it.

    You can refresh the intsllisense cache, but in general you wan tto ignore bogus errors from Intellisense.


    Tibor Karaszi, SQL Server MVP (Web Blog)

    Friday, April 8, 2016 7:00 AM