Do you know this FACTOID about Foreign Key Constraints in SQL Server?

Reading Time: 3 minutesThere is an interesting factoid you should know when it comes to working with foreign key constraints in SQL Server. Normally, foreign key constraints are linked to a Primary Key column in a parent table Take a look at the following Books and BookSales tables: CREATE TABLE Books ( BookID Continue Reading

How to make a column NOT NULL in SQL Server: Explained with Examples

Reading Time: 3 minutesYou may find yourself needing the change the definition of a table or column from time-to-time while working as a database professional. One change you may need to make is changing a column from nullable to non nullable. It may have been decided that we actually don’t want NULL to appear Continue Reading

Difference between unique constraints and primary key constraints: Answered with examples

Reading Time: 4 minutesA primary key constraint and a unique constraint are both meant to enforce uniqueness in column(s). Since that’s true, it begs the question: What’s the difference? In this very brief tutorial, we’ll discuss the two main differences between primary key constraints and unique constraints. Difference # 1: Primary key constraints Continue Reading

SQL Server Functions VS Stored Procedures: What’s the difference?

Reading Time: 6 minutesTwo of the most helpful objects you can create in Microsoft SQL Server are user-defined functions and stored procedures. If you are just starting out with SQL Server, you might wonder “What’s the difference?“. In this very brief tutorial, we’ll discuss the difference between SQL Server functions and stored procedures Continue Reading

SQL Server Filtered Indexes: Explained for Beginners

Reading Time: 5 minutesFiltered indexes in SQL Server can dramatically increase the efficiency of queries against data in your database. They are a fantastic optimization tool you should understand and remember during the design and development of tables in your database! In this brief tutorial, we’ll discuss what a filtered index is and Continue Reading

Why can’t I add a foreign key constraint? ANSWERED!

Reading Time: 4 minutesWhen attempting to create a foreign key constraint on a table, you may receive an error message very similar to the following: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint “constraint_name”. The conflict occurred in database “DatabaseName”, table “TableName”, column ‘ColumnName’. This may be happening because you are Continue Reading