SQL

Is it possible to have more than one identity column in sql

I want to create more than one identity column in my table. So is it possible to do that. No, We can not do that. Let’s understand by example. I am trying to create a table which has two column… Continue Reading →

How to get random row in sql server

We can find the random row by using newid() function in sql. I am using sql server 2012 and ReportServer database. select top 1 * from DBUpgradeHistory order by NEWID() I hope this code is helpful. Happy coding 🙂

How to get random number in sql server

You can achieve this by following this code. In this code you can find 4 digit random number. select cast(rand() * 10000 as int ) as RandNo If you want 6 digit random number then you use the following code… Continue Reading →

While loop in sql server

declare @i int=10 while(@i< =20) begin print @i set @[email protected]+1 end I hope this code is helpful. Happy coding 🙂

Find Nth highest salary using Dense_rank function in sql

In this article we learn how to find nth highest salary using Dense_Rank function is sql. Let’s create a table and name it table1. CREATE TABLE [table1]( [id] [int] IDENTITY(1,1) NOT NULL, [Name] [varchar](30) NULL, [Salary] [int] NULL, [DepId] [int]… Continue Reading →

How to generate an insert script that includes all stored rows in sql server

In this article we learn how to generate an insert script that includes all stored rows in sql server.

Maximum and minimum salary department wise in Sql server

Let’s first create a table having four fields. CREATE TABLE table1( [id] [int] NULL, [Name] [varchar](30) NULL, [Salary] [int] NULL, [DepId] [int] NULL ) Now insert some record in this table. INSERT table1 VALUES (1, ‘test1’, 1200, 1) INSERT table1… Continue Reading →

Creating Database When MDF is Compressed

Here you will see how to create a database when the MDF is compressed.

How to Write a Stored Procedure in SQL Server

In this article we learn what a Stored Procedure is and how to make a Stored Procedure in SQL Server.

Joins in SQL Server

In this article we learn about joins in SQL Server. A join is used to combined data from two or more tables in SQL.