20 May 2016 Sudhanshu Ranjan 654
What is the difference between UNION and UNION ALL?
UNION and UNION ALL both are merged the data of two different tables in single table. UNION display only the unique data in both table whereas UNION ALL display duplicate data also. Column name should be match on both table.
UNION ALL is typically faster than UNION.
CREATE TABLE [dbo].[employee]( [id] [int] IDENTITY(1,1) NOT NULL, [name] [varchar](50) NULL, CONSTRAINT [PK_employee] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
CREATE TABLE [dbo].[salary]( [id] [int] NULL, [salary] [int] NULL ) ON [PRIMARY]
select ID from employee UNION select id from salary
select ID from employee UNION ALL select ID from salary
Sudhanshu Kumar Ranjan | Lead Engineer at HCL Technologies | Expertise in Microsoft Technology | Author | Blogger | Programmer
Connect with him on Facebook | Google+ | LinkedIn | Twitter
- What is Angular 2 and how it is different from Angularjs 1
- Uninstall an Application Using the Command Line.
- set default page while using “Area” in MVC application
- Create and consume a simple WCF Restful service using AngularJs application
- How to setup angular 2 environment and build a project
- What is Prime Number? Print Prime Number using C#
- Difference between ref and out parameters with example.
- Factorial Number Program in C#
- What is the Difference between Overriding and overloading
- Difference Between ViewResult() and ActionResult() in MVC ?
Leave a comment
Search In This Website
- Bind dropdown in MVC using jquery with C#
- Paging in MVC using C# with razor
- TypeError: $(...).autocomplete is not a function
- How to implement CAPTCHA in MVC 4 using C# Asp.net.
- How to use CKEditor in MVC application/ Asp.net application.
- Bind gridview and paging example in angularjs
- secure connection failed firefox fix
- Code first approach with CRUD operation in MVC Application
- datepicker textbox in mvc 4 using JQuery
- How to install asp.net mvc 5 in visual studio 2012
- Sql Server(9)
- Entity Framework(3)
- Angular Js(6)
- Web API(0)
- Web Service(1)
- Crystal Report(0)
- My SQL(5)
- Visual Studio(18)
- Knockout JS(0)
- Microsoft Office(0)
- Node JS(0)