T-SQL Tutorials - TSQLTutorials.com



The TRUNCATE statement is used for removing all records from a table. The TRUNCATE statement is not a logged transaction. The TRUNCATE Statement has a simple syntax:

  • TRUNCATE tablename


In this example we will assume that the 'Employees' table contains the follow columns: 'Name', 'Position', 'Office' and 'Salary'. SELECT *
FROM Employees
Here is a sample resultset from the above SELECT query:

Joe GrapeManagerHouston80000
John PlumSoftware DeveloperHouston65000
Frank AppleSoftware DeveloperCleveland62000
Patty PineappleSoftware DeveloperCleveland60000
Judy PeachSoftware DeveloperBoston50000
Jane OrangeProject ManagerHouston75000

We'll use the TRUNCATE statement to remove all the records from the table. TRUNCATE TABLE Employees

Now we'll try to query the table again. We will find out that there are no longer any rows in the table. SELECT *
FROM Employees
No Records

Microsoft SQL Server 2008 R2 Standard Server License key +5CAL FactorySealedPack

Price: $495
Buy It Now
Add-On Microsoft SQL Server 2008 R2 5CAL Standard Enterprise Datacenter Sealed!

Price: $199
Buy It Now
Brand New - Microsoft SQL Server 2014 Standard Edition SP2 and 25 CAL License

Price: $899
Buy It Now
Microsoft SQL Server 2012 Standard 10CAL +Server License Key Factory Sealed Pack

Price: $949
Buy It Now
Factory Sealed- 228-10602 Microsoft SQL Server 2016 Standard 10 CAL NEW!!

Price: $2169.99
Buy It Now
Factory Sealed - 228-09180 Microsoft SQL Server 2008 R2 Standard 10 CAL

Price: $1599
Buy It Now

Copyright 2017 - TSQLTutorials.com