SQL Server
Welcome to SQL Server section of C# Corner. In this section, you will find various SQL Server related source code samples, articles, tutorials, and tips.


  • How Much Will Compression Really Gain Me

    Did you know that compression can gain you more than just space on a disk; it can allow you to fit more data into the buffer pool? That means queries have faster and more efficient reads which can ...
  • How To Check If A String Contains A Substring In SQL Server

    This blog explains how to check, if a string contains a substring in SQL Server or not.
  • How To Find Random Record In SQL Server

    In this blog. I will explain you how to find random record in SQL server. This is most common interview question. The CHECKSUM function returns the checksum value computed over a table row, or over...
  • How To Calculate Time (Years, Months, And Days) Between Two Dates

    In this post, we will learn how to calculate the time between two dates in years, months, and days format. There is a special function for getting a perfect year, month, and day count.
  • Views In SQL Server

    In this blog, we will discuss how to work with Views in SQL Server and explain concepts with an example in a simple way. I hope this is very useful for beginners to help them understand the basic c...
  • Merging Different Row Cells Into One In SQL

    This article is about merging different row cells into one for the purpose of reporting. Sometimes we need to customize according to the client’s requirements.
  • Updating Dynamic Columns On The Go In SQL

    I hope you all are doing fine. This particular article is about updating the dynamic columns on the go.
  • Keeping Large Table Statistics Current - TF2371

    Statistics are the magic ingredient that helps the query optimizer create its best guess for generating an execution plan. Keeping statistics as accurate as possible will give the optimizer the inf...
  • Creating A Database In SQL Server 2017 - A Quick Recap

    In this video session, we will quickly walk through the steps of creating a simple Database in SQL Server 2017 Express Edition.
  • How To Create A Stored Procedure In SQL Server Management Studio

    In this article you will learn about how to create stored procedure in SQL SERVER MANAGEMENT STUDIO. What is Store Procedure? Why do we use SET NOCOUNT ON in stored procedure? How to write comment ...
  • Most Asked SQL Server Interview Questions and Answers

    In this article you will learn about the most asked SQL Server Interview questions. Top 50 SQL Server Interview Questions and Answers. How to delete a table in SQL Server? What is a function in SQL...
  • Identity Column In SQL Server

    In this article, we will learn about identity function and how we Reset Identity Column in SQL Server. Identity keyword is used in SQL Server to Auto Increment Column value.
  • How To Display Date And Time In Duration (Such As One Hour Ago) In SQL Server

    Today, in this post, I am going to explain the SQL statement which is used to to get the date and time difference in a valid format like 1 hr ago, or 30 min ago, or 1 week ago, 1 month ago, and so ...
  • SQL Server Integration Services (SSIS) - Real time Examples Of Data Flow Transformations In SSIS

    In my series of articles there are a few scenarios where we need to take care of some real-world samples and examples to help explain concepts to the end users. This is part 49 of the series of art...
  • Create Unique Key Constraint Through GUI In SQL Server

    Learn how to create a Unique Key Constraint in SQL Server through GUI without writing any T-SQL query.
  • Add Primary Key/Unique Keys/Foreign Keys After Table Creation Using SQL Query

    Today, we will learn how to add Primary Key, Unique Keys, or Foreign Keys on a table after the table is created. We will be using a simple query.
  • Resolving The "Wait Operation Timed Out" Error When TFS Stops Working

    A few days ago our system administrator installed the Microsoft test manager 2012 on Microsoft Team Foundation Server 2010(TFS 2010). Suddenly our TFS stopped working. TFS was not able to extract t...
  • An Overview Of User Defined Functions In SQL Server

    In this article, we will learn how to create and use user-defined functions in SQL server. The function we write for reusability purpose to avoid complexity and duplication of code. User-defined fu...
  • Database Backup And Restore In SQL Server

    Backup and Restore are common functions of a database administrator. In this tutorial, you learn how to create a SQL Server database backup and restore it back using SQL Server tools.
  • Generate SQL Table, Store Procedure and C# Class Via Uploading Excel

    I am explaining how we can create Table, Store procedure , and C# class via uploading excel and it can save developer’s time.
  • TRY...CATCH And RAISERROR With Stored Procedure

    In this article, we’ll see how to handle the error and raise an error in SQL Server with a stored procedure.
  • How To Track Changes In Stored Procedure, Function, And View In SQL Server

    SQL Server DDL Trigger is a special kind of trigger that fires in response to Data Definition Language (DDL) statements – CREATE, ALTER, DROP (Table, Function, Index, Stored Procedures, Views.. etc).
  • Best Practices And Programming Guidelines In SQL Server - Part Two

    In this article, I am going to explain about best practices and programming guidelines in SQL Server, for all SQL programmers.
  • Learn About Windows Ranking Function

    I am writing this article to share knowledge about Windows Functions or Windows Ranking Function(It is a sub part of the Windows Functions). There are many windows functions introduced in SQL Serve...
  • How To Clean SSISDB History Periodically

    This blog exclusively explains the process of cleaning the execution history of SQL Server Integration Services packages from SSISDB.