How can compare two temptables in c# or Sql [Resolved]

Posted by Sekar.C under C# on 7/25/2012 | Points: 10 | Views : 1506 | Status : [Member] | Replies : 7
Hi,
How can compare two temptables in c# or Sql
Eg:
tempTable 1:
Number Name Qty
12301 AAA 1
12303 ccc 1
12302 eee 2
12304 www 7

tempTable 2
Number Name Qty
12300 sss 1
12301 qqqq 1
12303 yyy 2

Expected Result
Number Description Qty(table1) Qty(table2)
12301 Part1 1 1
12303 paflklkfdk 1 2

Regards
Sekar.c



Responses

Posted by: Sekar.C on: 7/28/2012 [Member] Starter | Points: 25

Up
0
Down

Resolved
Hi,
This code use for more the two check box checked time compare the values in c#
 Download source file

Regards
Sekar.c

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bhuvana on: 7/25/2012 [Member] Starter | Points: 25

Up
0
Down
Hi
try this
 Download source file

Thanks & Regards
Bhuvana

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Megan00 on: 7/25/2012 [Member] Starter | Points: 25

Up
0
Down
I can not see your answer.

Never give up! Smile to the world!
http://excelcsharp.blog.com/

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Megan00 on: 7/25/2012 [Member] Starter | Points: 25

Up
0
Down
Hello, try this one:
http://www.agr.kuleuven.ac.be/vakken/statisticsbyR/ANOVAbyRr/multiplecomp.htm

Never give up! Smile to the world!
http://excelcsharp.blog.com/

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sekar.C on: 7/26/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Am using 1 grid view it display some records from DB in this grid have check box if I check 2 check boxes That time this (attached code) is working but I need if I check more than 2 check boxes how I can do these compare process. Anybody please give the solution, attached my code here.
 Download source file

Regards
Sekar.c

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 7/26/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down

DECLARE @T1 TABLE(ID INT, Data1 sysname, Data2 INT);


DECLARE @T2 TABLE(ID INT, Data1 sysname, Data2 INT);

INSERT INTO @T1 VALUES (12301,'AAA', 1);

INSERT INTO @T1 VALUES (12303, 'ccc',1);

INSERT INTO @T1 VALUES (12302 ,'eee',2);

INSERT INTO @T1 VALUES (12304,'www',7);


INSERT INTO @T2 VALUES (12300 ,'sss', 1);

INSERT INTO @T2 VALUES (12301 ,'AAA', 1);

INSERT INTO @T2 VALUES (12303 ,'ccc', 1);


SELECT To1.ID, To1.Data1, To1.Data2

FROM @T1 AS To1 LEFT OUTER JOIN

(

SELECT T1.Data1, T1.Data2 FROM

@T1 AS T1 INNER JOIN @T2 AS T2

ON T1.Data1 = T2.Data1 AND T1.Data2 = T2.Data2

) AS To2 ON To1.Data1 = To2.Data1 AND To1.Data2 = To2.Data2

WHERE To2.Data1 IS NULL

UNION ALL

SELECT To1.ID, To1.Data1, To1.Data2

FROM @T2 AS To1 LEFT OUTER JOIN

(

SELECT T1.Data1, T1.Data2 FROM

@T1 AS T1 INNER JOIN @T2 AS T2

ON T1.Data1 = T2.Data1 AND T1.Data2 = T2.Data2

) AS To2 ON To1.Data1 = To2.Data1 AND To1.Data2 = To2.Data2

WHERE To2.Data1 IS NULL

Result will be :-
12302 eee 2
12304 www 7
12300 sss 1


Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Oswaldlily on: 7/26/2012 [Member] Starter | Points: 25

Up
0
Down
Description alone dont knw from where its coming..
create table tbl1
(
Number int,
Name varchar(20),
Qty int
)
--insert into tbl1(Number,Name,Qty) values('12301','AAA','1')
--insert into tbl1(Number,Name,Qty) values('12303','ccc','1')
--insert into tbl1(Number,Name,Qty) values('12302','eee','2')
--insert into tbl1(Number,Name,Qty) values('12304','www','7')
create table tbl2
(
Number int,
Name varchar(20),
Qty int
)
--insert into tbl2(Number,Name,Qty) values('12300','sss','1')
--insert into tbl2(Number,Name,Qty) values('12301','qqq','1')
--insert into tbl2(Number,Name,Qty) values('12303','yyy','2')
create table tbl3
(
Number int,
Descrip varchar(20),
Qty1 int,
Qty2 int
)

select t1.Number,(t1.Qty) as Qty1,(t2.Qty) as Qty2 from tbl1 t1 inner join tbl2 t2 on t1.Number=t2.Number

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response