The SQL CREATE TABLE ... AS SELECT
statement enables you to insert the results of a query into a new table.
Tag: how to
SQL SELECT INTO Statement
The SQL SELECT INTO
statement is a Sybase extension that can be used to insert the results of a query into a table (or a variable, depending on the DBMS).
SQL INSERT INTO… SELECT Examples
The SQL INSERT
statement is most commonly used to insert individual rows into a table.
But you can also insert the results of a query into a table. This means that you can insert multiple rows at once (as long as they’re returned by the query).
Continue readingExecute a Trigger Only When Certain Columns are Updated (SQL Server)
SQL Server has the UPDATE()
function that you can use within your DML triggers to check whether or not a specific column has been updated.
While this function only accepts one column, there’s nothing to stop you from including multiple UPDATE()
clauses with AND
or OR
to test for multiple column updates.
Find Out if a Partition is Compressed in SQL Server (T-SQL)
In SQL Server, you can query the sys.partitions
system catalog view to find out whether or not a partition has been compressed.
In particular, the data_compression
column tells you whether it’s compressed or not. The data_compression_desc
column tells you what type of compression it uses. If it isn’t compressed, it returns NONE
.
SQL Joins Tutorial
A SQL join is where you run a query that joins multiple tables.
This SQL joins tutorial presents basic examples of SQL joins, as well as an introduction to the various join types.
Continue readingBasic SQL Queries
This article contains examples of basic SQL queries that beginners can use to retrieve data from their databases.
Continue readingSQL DELETE for Beginners
This article contains basic SQL DELETE
statements that beginners can use to delete data from their database tables.
SQL UPDATE for Beginners
This article contains basic SQL UPDATE
statements that beginners can use to update data in their database tables.
Return All Rows From a Specific Partition in SQL Server (T-SQL)
When you create a partitioned table in SQL Server, you specify which values go into each partition.
This is done when you create the partition function. When you create the partition function, you specify boundary values, which determine which values go into each partition.
Once you’ve created your partitioned table, and you’ve inserted data, you can run a normal SELECT
statement to return data, just as you would with a non-partitioned table (actually, even non-partitioned tables have one partition).
But did you know that you can also specify which partition you want data from?
You can do this with the help of the $PARTITION
system function in your WHERE
clause.