SQL commands

Esat Erkec
Listing temporary tables in tempdb database

How to drop temp tables in SQL Server

March 23, 2020 by

Temporary tables, also known as temp tables, are widely used by the database administrators and developers. However, it may be necessary to drop the temp table before creating it. It is a common practice to check whether the temporary table exists or not exists. So, we can eliminate the “There is already an object named ‘#temptablename’ in the database” error during the temporary table creation.

Read more »
Ahmad Yaseen
Max() function example 7

SQL Server MAX() aggregate function

March 19, 2020 by

SQL Server provides us with several aggregate functions that can be used to perform different types of calculations on a set of values, and return a single value that summarized the input data set. These SQL Server aggregate functions include AVG(), COUNT(), SUM(), MIN() and MAX().

Read more »
Bojan Petrovic
An executed CREATE VIEW SQL script showing data returned only for the SELECT statement in SSMS

CREATE VIEW SQL: Modifying views in SQL Server

March 5, 2020 by

In my previous article, we looked at how to use the CREATE VIEW SQL statement to create views. In this one, we are moving on and focusing on how to modify views. We will continue using examples on a sample database and data created in the first write-up so in order to follow along, head over and read the Creating views in SQL Server part before starting with this one.

Read more »
Emil Drkusic
The data model we'll use to explain user-defined functions

Learn SQL: User-Defined Functions

February 25, 2020 by

You can create several user-defined objects in a database. One of these is definitely user-defined functions. When used as intended, they are a very powerful tool in databases. In today’s article, we’ll see how to create, change and remove them from the database, as well as how to use them. So, let’s dive into the matter.

Read more »
Emil Drkusic

Learn SQL: How to Write a Complex SELECT Query

February 4, 2020 by

In my career, I’ve heard many times, things like “How to write a complex SELECT query?”, “Where to start from?” or “This query looks so complex. How you’ve learned to write such complex queries?”. While I would like to think of myself as of a brilliant mind or genius or add something like “query magician” to my social network profiles, well, writing complex SQL wouldn’t be the only thing required to do that. Therefore, in this article, I’ll try to cover the “magic” behind writing complex SELECT statements.

Read more »