This article provides an overview of the INNER JOIN
in SQL, as well as some basic examples.
SQL Right Join
This article provides an overview of the RIGHT JOIN
in SQL, as well as some basic examples.
Check the Space Used by a Table in SQL Server
SQL Server has a system stored procedure called sp_spaceused
that enables you to check the size of a table in a database.
You can use it to check the number of rows, disk space reserved, and disk space used by a table, indexed view, or Service Broker queue in the current database, or the disk space reserved and used by the whole database.
Continue readingSQL Alias Explained
The SQL alias is a nice little feature of SQL that allows you to write more concise code and create column names when no column name exists.
There are two SQL alias types; column aliases, and table aliases. In this article, I provide an overview of both.
Continue readingSwitch-In a Partition in SQL Server (T-SQL)
In SQL Server, you can switch partitions in and out of a partitioned table.
You can do this with the ALTER TABLE
statement. Basically, it goes like this:
ALTER TABLE OldTable
SWITCH TO NewTable PARTITION x
This switches the partition for OldTable
into partition x
of NewTable
(where x
is the partition number).
Switch-Out a Partition in SQL Server (T-SQL)
In SQL Server, partition switching allows you to load large amounts of data in or out of a table very quickly. This saves you from having to run delete or insert statements, and can be very useful when working with large data sets.
You can use the ALTER TABLE
statement to switch a partition in or out of a table.
To switch a partition out of a table, the code goes like this:
ALTER TABLE Table1
SWITCH PARTITION x TO Table2
This switches partition x
from Table1
to Table2
(where x
is the partition number).
SQL INSERT for Beginners
This article contains basic SQL INSERT
statements that beginners can use to insert data into their database tables.
SQL CREATE TABLE for Beginners
This article contains basic SQL CREATE TABLE
statements that beginners can use to create basic tables for their database projects.
SQL Server ROWCOUNT_BIG()
In SQL Server, you can use the ROWCOUNT_BIG()
system function to return the number of rows affected by the last T-SQL statement.
It works exactly the same as @@ROWCOUNT
, except that ROWCOUNT_BIG()
returns its result as a bigint.
12 Commonly Used SQL Operators
In SQL, an operator is a special character or keyword specifying an action that is performed on one or more expressions.
SQL operators are an integral part of SQL, and they enable us to write queries that return relevant results.
In this article, I present 12 of the most commonly used SQL operators when writing SQL queries.
Continue reading