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 →
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 🙂
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 →
declare @i int=10 while(@i< =20) begin print @i set @[email protected]+1 end I hope this code is helpful. Happy coding 🙂
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 →
In this article we learn how to generate an insert script that includes all stored rows 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 →
Here you will see how to create a database when the MDF is compressed.
In this article we learn what a Stored Procedure is and how to make a Stored Procedure 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.