Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to truncate table with SQL Server 2008?

I want to truncate table but when column value equals NULL

truncate table FB_Player where FB_Player.Status ='NULL'
like image 665
Myworld Avatar asked Sep 21 '13 15:09

Myworld


People also ask

How do you truncate a table in SQL Server?

To remove all data from an existing table, use the SQL TRUNCATE TABLE order. You can also use the DROP TABLE command to delete an entire table. But Truncate will remove the entire table structure from the database, and you will need to recreate the table if you want to store any data.

How do I truncate all tables in SQL Server?

The SQL TRUNCATE TABLE command is used to delete complete data from an existing table. You can also use DROP TABLE command to delete complete table but it would remove complete table structure form the database and you would need to re-create this table once again if you wish you store some data.

What is the procedure for truncating a table?

TRUNCATE TABLE removes all rows from a table, but the table structure and its columns, constraints, indexes, and so on remain. To remove the table definition in addition to its data, use the DROP TABLE statement.


1 Answers

You can not Use Where Clause with truncate. Truncate clears all the data from a table without any condition. Instead you use Delete command.

like image 80
Rakesh Mishra Avatar answered Sep 29 '22 16:09

Rakesh Mishra