October 25, 2010 at 10:25 am
Dear All ,
How to add 2 Temp-table
Temp Table 1 :
select no,name,age insert into #temp1 from emptable
Temp Table 2 :
select address,state,county insert into #temp2 from locatetable
now i want select all the column in one temp-table
Ex: no,name,age,address,state,county ===>all columns in one table
How can i do this kindly advise me ........
Thanks & Regards,
Hasan
October 25, 2010 at 10:38 am
you'll have to provide the linking criteri that shows that an address in one table belongs to the employee in the other;
and you'll simply use a left outer join to get it all in a single statelemt:
select
emptable.no,
emptable.name,
emptable.age,
locatetable.address,
locatetable.state,
locatetable.county
from emptable
--this is what is missing:
--how are the two tables related? addrID?EmpID?
LEFT OUTER JOIN locatetable ON emptable.no = locatetable.no
Lowell
October 25, 2010 at 11:04 am
i dont have a any same column like id..
two table column's are fully different...
Kindly advise me how to add two temp-table columns
October 25, 2010 at 12:17 pm
reliably? you cannot. to join data from two tables, there must be a join criteria of some kind.
if you have 5 employees in one table, how do you know which address is theirs in another.
there must be some column the two share.
if there is not, you have a design problem.
show us the CREATE TABLE definitions of both tables, so we can really help you.
if both tables have an identity, maybe you can make an assumption nad use row number to generate the join, since that would need something to order the data by.
Lowell
October 25, 2010 at 1:07 pm
CELKO (10/25/2010)
The best book for a complete beginner is THE MANGA GUIDE TO DATABASES.
Awesome book, even for the not-so-beginner.
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 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply