Do You Make These Mistakes When Using SQL CURSOR?

Total: 1 Average: 5

For some people, it’s the wrong question. SQL CURSOR IS the mistake. The devil is in the details! You can read all sorts of blasphemy in the entire SQL blogosphere in the name of SQL CURSOR.

If you feel the same way, what made you come to this conclusion?

If it’s from a trusted friend and colleague, I can’t blame you. It happens. Sometimes a lot. But if someone convinced you with proof, that’s a different story.

We haven’t met before. You don’t know me as a friend. But I hope that I can explain it with examples and convince you that SQL CURSOR has its place. It’s not much, but that small place in our code has rules.

Read More

Virtual Columns and Functional Indexes

Total: 1 Average: 5

Much too often, we see poorly written complex SQL queries running against the database tables. Such queries may take a very short or a very long time to execute, but they consume a huge amount of CPU and other resources. Nevertheless, in many cases, complex queries provide valuable information to the application/person. Therefore, it brings useful assets in all varieties of applications.

Read More

Understanding SQL Server ALTER TABLE ADD COLUMN Statement

Total: 1 Average: 5

This article describes the SQL Server ALTER TABLE ADD COLUMN statement. The purpose of this statement is to add a new column to an existing table. Also, the article will clarify the following use cases:

  1. Add multiple columns.
  2. Add a new primary key column.
  3. Add a new foreign key column.
  4. Add new columns that have computed columns.
  5. Add a new column that has CHECK and UNIQUE constraints.
Read More

Using INNER JOIN to Combine SQL Server Tables and Display Them in ASP.NET Webforms

Total: 1 Average: 5

This article describes the ways of using an INNER JOIN to combine results from two tables in the SQL Server database and display them in an HTML5 table inside an ASP.NET webform. Additionally, it touches on the question of using CSS3 (cascading style sheets) to apply a style to the HTML5 table in an ASP.NET webform.

Let’s begin.

Read More

SQL DROP TABLE Statement and Various Use Cases

Total: 1 Average: 5

The SQL DROP TABLE statement serves to drop the table from the database. It removes the table and its data and indexes associated with it. The statement is irreversible. Thus, you can restore the table only by restoring the backup.

This article covers the following cases:

  1. Delete one or multiple tables.
  2. Delete the table used in a View.
  3. Delete the table having a foreign key.
  4. Delete the table having clustered and non-clustered indexes.
  5. Delete the table from the replication setup.
Read More

Everything You Need to Know About SQL CTE in One Spot

Total: 1 Average: 5

The first time Karl heard of SQL Server CTE was when he was looking for something to make his SQL code easier for the eye. It’s kind of a headache when you look at it. Anton, his concerned colleague, asked him about CTE. Karl thought Anton was referring to his headache. Maybe he heard it all wrong, so he answered, “Of course not.” The funny thing is, he was referring to Chronic Traumatic Encephalopathy, also a CTE – a neurodegenerative disease caused by repeated head injuries. But based on Karl’s response, Anton knew for sure that his colleague was clueless about what he was saying.

What a crazy way to introduce CTEs! So, before you get into the same boat, let’s clarify, what is SQL CTE or Common Table Expressions in the SQL world?

You can read the basics here. Meanwhile, we’ll learn a bit more about what happened in this unusual story.

Read More

Mastering the Use of Stoplists With SQL Server Full-Text Search (FTS)

Total: 1 Average: 5

Creating and managing stoplists serves as one of the main components responsible for improving the Full-Text Search performance alongside reducing the size of the index. This article aims to help you master the job in-depth and implement multiple strategies to create stoplists on simple but interesting examples.

We’ll also highlight the importance of different methods to generate stoplists and clarify how to choose the most suitable method.

Read More