From the course: Designing Database Solutions for SQL Server 2016

Unlock the full course today

Join today to access over 23,300 courses taught by industry experts.

Create temp tables and table variables

Create temp tables and table variables

- Physical tables in SQL Server 2016 are persisted to disk, and include either a heap of unordered records or a clustered index to sorted records. When you only need a table structure for a short period, such as when you're in the middle of an operation and need to store table values while some other process completes, you can create a table and then drop it when you're done. That's one way. But there's a couple of better options when it comes to creating a temporary table solution for you to consider when developing a design for your SQL Server databases. Let's take a look at these by creating a new database that we can work with. The first one I want to take a look at is called temporary table. Temporary tables are created using the standard CREATE TABLE syntax, but they use a special pound sign in the name. This pound symbol notation will create a local temporary table in tempdb instead of in the current working database. The table will be removed as soon as the user that created…

Contents