

This would remove all entries from our table that match our condition of the Height being greater than 18. Using our table above of dogs, our query would look like this: DELETE FROM Cute_Doggos WHERE dbo.Cute_Doggos.Height > 18 For that, we'll add a condition and the syntax will look like so: DELETE FROM name_of_table WHERE conditions_exist The vast majority of the time when you use the delete functionality you'll want to be a bit more targeted with your approach. This approach allows us to keep the column names, data types, indexes, and overall table structure in tact without deleting the actual table.Īs a side note, if your intended purpose is to delete all of the rows within a table, the faster approach would be to use the TRUNCATE TABLE statement as it uses far fewer system resources. I have used this statement many times to clear a table after it was filled with test data. That may be your intended purpose and the longer you write SQL the more cases you'll find to use the delete statement in this capacity. So for our example table above, the query would look like the following: DELETE FROM Cute_Doggos The action is as simple as the name itself and here is the base syntax: DELETE FROM name_of_table ***With this syntax you will delete all rows of data within the entire table.*** Onto the core of this article - deleting data.

If you wish to do that, Microsoft has some great in-depth information on the SQL Delete statement. Listening, behaving, not slobbering on everythingĪs you may have guessed, this is fictitious data from a table I've concocted out of thin air :) However, I hope it illustrates the data well enough for our purposes.Īs with most aspects of technical nature, it never hurts to check the official documentation as well. Here is the table, aptly named Cute_Doggos, that we'll be using as our example to start removing data from: Name I'm here to (hopefully) shed some light on one of those fundamentals of working with data: deleting an entire row of data.Īlthough we're not going to go over the process for establishing a table in SQL or populating that table with data/updating that data, I've linked those other articles in case you'd like to learn more or just need a refresher.Īlright, now the fun part - let's start deleting data from a table! SQL Delete Row Overview While I celebrate its resiliency (SQL was created in 1974 with an initial release of 1986) within the development community, I also know that when working with data it can feel like even the fundamentals are stressful and frightening. Hence my comment about having well-defined boundaries on syntax. SQL is structured with a clear and concise manner of operation in which the user's input dictates the data returned. Its straightforwardness and simplicity appeal to my desire to have well-defined boundaries in terms of what the language will and will not let me "get away with" regarding syntax.
#Delete query syntax professional#
I make no qualms about how much I enjoy working with SQL both in my professional and personal projects.
