How can I delete multiple records from a table by using a view as the filter?

By using the DELETE operation, you can join a table with a view to delete the matching rows from the table. The code in Listing 2 shows you how to use a view called v1 as a filter to delete rows from a table called t1. The code initially creates two tables and a view, inserts some sample data, then deletes rows from the first table, which has an ID that matches the key of the view.

A Sad Farewell

This month, we say a sad farewell to Answers from Microsoft, which debuted in SQL Server Magazine's September 2001 issue. We at the magazine are grateful to the members of the SQL Server development team for the time they've spent responding to readers' questions and selecting questions and answers for this column. In developing Yukon and working on other projects, the team members face severe time constraints and have decided to discontinue this column. You can still submit questions to the Microsoft SQL Server newsgroups at and to SQL Server Magazine's technical forums at

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.