Search code examples
sqlsql-serverwhere-clausesql-delete

How do I delete data using the primary key in SQL Server?


Working on a small database project, and one of the requirements is to show how to delete data using the primary key. The exact statement is

  • Show one delete statement that use a primary key to delete data

However, I can't figure out what the exact syntax for that would be. Could anyone show me a quick example?


Solution

  • That's a basic delete statement. Assuming table mytable and primary key id:

    delete from mytable where id = 1