SQL Server Create Table 2 Primary Key

SQL Server Create Table 2 Primary Key

Recently, my team was required to create tables with multiple primary keys in SQL Server. We analyzed the requirement and identified a few simple approaches to achieve this. In this article, I will walk you through multiple ways to do this task. Remember that this is known as Composite Primary Key. SQL Server Create Table … Read more

Cannot Define Primary Key Constraint On Nullable Column In Table

Cannot Define Primary Key Constraint On Nullable Column In Table

Recently, I was working on one critical requirement where I was trying to alter 2 primary keys for a table in SQL server. But after executing the SQL script, I got this error. In this article, I will walk you through the complete steps I followed to fix this issue. I was executing the below … Read more

How To Find Temp Table In SQL Server

How To Find Temp Table In SQL Server

As a senior developer, I used to be required to work with temporary tables. But as you know, the temp table is crucial while working with an SQL server. So, I have identified a few approaches to this. In this article, I will walk you through all those approaches individually. Approach-1: Using the tempdb System … Read more

How To Get Table Count In SQL Server

How To Get Table Count In SQL Server

As a senior SQL developer, I often get the requirement to determine the number of tables in an SQL server database. I analyzed and identified a few approaches to help you achieve this task. I will walk you through all those approaches individually with examples and best practices in this article. Approach-1: Using sys.tables The … Read more

SQL Server Remove Duplicates From A Table

SQL Server Remove Duplicates From A Table

As a developer working in SQL Server, I often have to remove duplicate data from the tables to free up space in our database. In this article, I will discuss different approaches to this task. Approach-1: Using the ROW_NUMBER() Function We can use the ROW_NUMBER() Function for this purpose. Let us consider the example below, … Read more

How To Save Query Results As Table In SQL Server

How To Save Query Results As Table In SQL Server

Recently, my team was required to save the query results into a table on an SQL server. We identified a few simple approaches to do this. In this article, I will walk you through all those approaches individually. Approach-1: Using SELECT INTO Statement Syntax Example Let us consider a real-time example in which we copy … Read more

How to Alter Table Column to Allow NULL in SQL Server

How to Alter Table Column to Allow NULL in SQL Server

As an SQL developer, I was required to modify the existing table structure and alter a column to allow null values. In this article, I will walk you through multiple ways to alter table columns to allow NULL in SQL Server with real-world scenarios. Approach-1: Using the ALTER TABLE statement This is the primary and … Read more

How to Find Table Dependencies in SQL Server

How to Find Table Dependencies in SQL Server

Understanding table dependencies is crucial to maintaining database performance as a database administrator or developer working with SQL Server. It also helps if you are trying to fix any issue without breaking the existing functionality. As part of my daily activity, my first step is to check the dependencies before starting work with any issues. … Read more

How To View Table In SQL Server Management Studio

How To View Table In SQL Server Management Studio

It is so simple to view a table in SSMS. As a senior developer in SQL Server, I have identified several approaches. In this article, I will walk you through each approach. Approach-1: Using Object Explorer in SSMS Follow the below steps. 1. Log in to the SQL Server Management Studio (SSMS) 2. Expand the … Read more

How To Copy Table Schema In SQL Server

How To Copy Table Schema In SQL Server

As an SQL developer, I must constantly duplicate the table structure without copying the data. This is where copying the table schema comes into the picture. Since this process is part of my daily activity, I have identified a few approaches to copying the table schema in SQL Server. In this article, I will walk … Read more