Sunday, August 3, 2014

Cross Join SQL



CREATETABLE [dbo].[EmDetails]
(
                [EmpId] [int] IDENTITY(1,1)NOTNULL,
                [Name] [varchar](50)NULL,
                [Address] [varchar](200)NULL,
                [City] [varchar](50)NULL
)
INSERTINTO EmDetails(Name,Address,City)VALUES ('Lalit','#1234','Chandigarh')
INSERTINTO EmDetails(Name,Address,City)VALUES ('Raman','#4567','Panchkula')
INSERTINTO EmDetails(Name,Address,City)VALUES ('Arjun','#111','Noida')
INSERTINTO EmDetails(Name,Address,City)VALUES ('Rohan','#321','Delhi')
INSERTINTO EmDetails(Name,Address,City)VALUES ('Raghav','#675','Noida')

CREATETABLE [dbo].[Tb_Dept]
(
                [DEPT_ID] [bigint] IDENTITY(1,1)NOTNULL,
                [DEPT_NAME] [varchar](50)NULL
)
INSERTINTO Tb_Dept(DEPT_NAME)VALUES ('HR')
INSERTINTO Tb_Dept(DEPT_NAME)VALUES ('IT')
INSERTINTO Tb_Dept(DEPT_NAME)VALUES ('SALES')

SELECT*FROM EmDetails CROSSJOIN Tb_Dept

SELECT*FROM EmDetails , Tb_Dept