Link Search Menu Expand Document

Truncate


This method truncates a table in the database.

Code Snippets

The following example truncates the [dbo].[Person] table.

using (var connection = new SqlConnection(connectionString))
{
    connection.Truncate<Person>();
}

Targeting a Table

To target a specific table, pass the literal table name.

using (var connection = new SqlConnection(connectionString))
{
    connection.Truncate("[dbo].[Person]");
}