How to Truncate a Table in SQL Server

Be very careful with TRUNCATE command. It will empty the content of your SQL Server table. This is useful in development, but you'll rarely want to do this in production.

--syntax
truncate table table_name;

truncate table users;

If the table contains an AUTO_INCREMENT column, the counter for it will also get reset. Note that this behavior is different vs some other databases like PostgreSQL for example, where you need to reset the counter yourself.

database icon
From SQL Server query to chart to Slack in seconds
Get to answers faster, together, with PopSQL and SQL Server