Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
like sql query ::
SQL
Select A.* Into #temp1 from(select
A.field
,B.field
,C.field
 from tableA A
inner join tableB B
    on A.field=B.field
inner join TableC C
    on B.field=C.field
where A.field= 11
) as A

Select B.* Into #temp2 from(select
P.field
,Q.field
,R.field
 from tableP P
inner join tableQ Q
    on P.field=Q.field
inner join TableR R
    on Q.field=R.field
where P.field= 11
) as B
SELECT a.*
     FROM #temp1 a
  Full outer  JOIN #temp2 b ON (a.field1 = b.field1
  and a.field2 = b.field2
  )
  WHERE b.field1 is null or b.field2 is null
Posted
Updated 14-Jul-15 23:00pm
v2

If your query is like that, in my opinion you don't need the temp table. Simply try:
SQL
select A.* 
from(select A.field
           ,B.field
           ,C.field
     from tableA A
          inner join tableB B on A.field=B.field
          inner join TableC C on B.field=C.field
     where A.field= 11) as A
 
Share this answer
 
Comments
roshan kumar deo 15-Jul-15 7:31am    
i want to use temp table Query in DataAdapter in asp.net
Wendelius 15-Jul-15 7:38am    
Why? What is the benefit?

Of course you can execute several commands in the same SqlCommand but breaking the logic into multiple statement very often slows down the execution and introduces unnecessary complexity.

Having that said, have a look at Executing multiple SQL statements as one against SQL Server[^]
Especially part "Using SqlDataAdapter for multiple SELECT statements"
A more simplified version that you can use is

SQL
select
A.field
,B.field
,C.field
 from tableA A
inner join tableB B
    on A.field=B.field
inner join TableC C
    on B.field=C.field
where A.field= 11
 
Share this answer
 
Comments
roshan kumar deo 15-Jul-15 7:32am    
I want use temp table sql query in dataadapter

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900