Video is ready, Click Here to View ×


In the previous video I created a table with the bare minimum information. If we want SQL Server to really understand how our database should work, we have to give it some extra information. The problem is though that if we try to run the CREATE TABLE command again the database will complain that the table already exists. This video will teach you how to DROP (delete) a table.

DROP TABLE Animals

Just remember that the syntax is almost identical to CREATE TABLE with the exception of having no parenthesis. That’s because we don’t have to specify any columns because we are getting rid of the whole thing.

Be warned before doing this though because it will delete all of the data inside of the table if there is any.

The second problem we will encounter is that if we try to get rid of the table and it has already been dropped. The problem here is that as we are practicing CREATE TABLE we don’t want to have to worry about figuring out if the table already exists before we try dropping it. We essentially want a way to say “If this table already exists, delete it.” There is actually a very easy way to do this in SQL Server:

DROP TABLE IF EXISTS Animals

Now, if the table does it exist it will be dropped, if it doesn’t then nothing will happen.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Support me! http://www.patreon.com/calebcurry

Subscribe to my newsletter: http://eepurl.com/-8qtH

Donate!: http://bit.ly/DonateCTVM2.

~~~~~~~~~~~~~~~Additional Links~~~~~~~~~~~~~~~

More content: http://CalebCurry.com
Facebook: http://www.facebook.com/CalebTheVideoMaker
Google+: https://plus.google.com/+CalebTheVideoMaker2
Twitter: http://twitter.com/calebCurry