Category Archives: Handling SQL tables

SQL DELETE TABLE Statement, Difference DELETE and TRUNCATE, Deleting Large Amounts Of Data

We distinguish two types of commands with data deleting purpose – SQL commands DELETE and TRUNCATE. Each is suitable for different situations. It is good to know them both and be able to choose the right one in a specific situation. DELETE Syntax (First Command is Optional): DELETE FROM dbo.Table WHERE <Condition>; or DELETE dbo.Table WHERE… Read More »

SQL CREATE TABLE- How to Create a Database Table (SQL Server)

Creating a table in the SQL Server database is a basic skill. While creating it using SQL command CREATE TABLE we define: Name of the table together with database definition and scheme List of the columns with appropriate data types, constraints and definition if the column can be empty (NULL vs. NOT NULL) Table can… Read More »

SQL UPDATE Statement – Syntax and Example of Updating Records

UPDATE Statement is used in SQL to change existing records in a table. This way, we can change one record, multiple records or all of them. Condition based on which are records restricted is placed in WHERE clause. Syntaxe – 3 Ways of UPDATE Usage A) Simple form: Change of the values in certain column… Read More »

SQL TRUNCATE TABLE Command – Don’t use DELETE when you don’t have to

T-SQL TRUNCATE command deletes all records in the table. Apart from DELETE (more in article SQL DELETE) command, there is no possibility to filter which record to delete. It is all or nothing. Truncate is on the other hand much faster compared to DELETE since it writes less into transaction log. TRUNCATE Syntax TRUNCATE TABLE dbo.Table;… Read More »

SQL MERGE Statement – INSERT, UPDATE, DELETE at once

SQL MERGE command is an advanced way of comparing data in two tables (Source and Destination). We compare records and based on match (or difference) we execute UPDATE, INSERT or DELETE according to the result of table comparison. We will use this mainly with data sync between objects/systems or with ETL processes in environments like… Read More »

SQL INSERT – Inserting Rows into Database Table (3 methods) + Common mistakes

SQL Command INSERT is suitable for situations when we want to insert entries into the table. Insertion of rows can be done in multiple ways (further description below): You can insert the values that you fixedly choose (INSERT INTO … VALUES (value1, value2, …)) You can insert the values into the table using script (SELECT… Read More »