DELETE is used to delete existing rows from a list.


FROM list_name [.{content_type_name | ATTACHMENTS}]
[WHERE where_condition];

The DELETE statement is used as follows:

  1. The list_name indicates the list to delete rows from. Optionally, you can also specify the content type, in which case only rows of the given content type will be deleted.
  2. The WHERE clause, if given, specifies the conditions that are used to identify the rows to delete. The where_condition evaluates true for all rows to be deleted. With no WHERE clause all rows in the list are deleted. See Operators And Functions for detailed examples of WHERE usage and available operators.

    Example: to delete rows from the list Employees where Active column is False:

    DELETE FROM Employees WHERE Active = False;

    The DefaultLimit option in the connection string places a default limit on the number of rows that can be deleted.

  3. When the procedure returns, the application can obtain the number of rows affected through the LastRecordsAffected property of the SharePointCommand class.

Code examples

Delete all inactive customers

using (var connection = new SharePointConnection(connectionString))
    using (var command = new SharePointCommand(@"DELETE FROM Customers WHERE Active = False", connection))
        Console.WriteLine("Affected rows = " + command.LastRecordsAffected);

Code result

Affected rows = 2

Skip Navigation Links.

Visa     MasterCard