July 30, 2008 at 10:21 pm
HI
i have two tables with different number of rows and no identity columns in each one
i want to join them and retrieve in single table
please help me
July 30, 2008 at 11:55 pm
You can use UNION to combine queries.
ex.
SELECT Name, City FROM Suppliers
WHERE Country = 'Mexico'
UNION SELECT Name, City FROM Customers
WHERE Country = 'Mexico'
July 30, 2008 at 11:58 pm
Create View v1
as
Select Eno,Ename from e1.dbo.emp
where Eno = 5
Union All
Select Eno,Ename from e1.dbo.empmast
where Eno = 5
Now,
Select Eno,Ename from v1
karthik
July 31, 2008 at 1:17 am
VENUGOPAL.RR (7/30/2008)
HIi have two tables with different number of rows and no identity columns in each one
i want to join them and retrieve in single table
please help me
How many rows are in each table? How many rows are you expecting in the output? What are the table structures? Identity columns are not essential for joining tables.
There's very little information to work with; you won't get an answer straight away, instead you will get a barrage of questions until enough is known about your problem. The following link provides guidelines on how to post a question to get an answer quickly:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Cheers
ChrisM
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 31, 2008 at 1:19 am
karthikeyan (7/30/2008)
Create View v1as
Select Eno,Ename from e1.dbo.emp
where Eno = 5
Union All
Select Eno,Ename from e1.dbo.empmast
where Eno = 5
Now,
Select Eno,Ename from v1
Karthik, why not just join the two tables on Eno? 😉
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 31, 2008 at 1:25 am
Karthik, why not just join the two tables on Eno?
Chris,
I do agree with you. We can use Join also.:D
karthik
July 31, 2008 at 9:49 am
i have two tables more than 10,000 rows in each table
each from different databases
and also having different number of rows
i want just marely join those tables and render in a single table
i want just as outter join
not cross join
July 31, 2008 at 9:57 am
Not enough information. Please post your table structure and give us an idea what the data looks like and what you want returned.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply