Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
hi alli m facing one problem.. in exceli have 2 different spreadsheetssheet 1 and sheet 2in sheet 1 i have suppouse following dataName Prod. valuea 24 100b 26 240a 33 120a 21 200c 26 240b 33 120d 24 100in sheet 2Name Prod. value a 24 100 d 26 240 a 33 120 e 26 240 a 21 200 c 26 240 d 24 100in this situation i want to find out the dropouts of sheet 1. (that persons which are not present the sheet 2)how can i compare these sheets?in this case i want the result asName Prod. valueb 26 244b 33 120Thanx & RegardsManu Verma
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts
Posted - 2006-08-11 : 07:36:52
Try this...
Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\Test.xls;HDR=YES','SELECT * FROM [Sheet1$]') as xwhere not exists (Select * from OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=C:\Test.xls;HDR=YES','SELECT * FROM [Sheet2$]') as ywhere x.Name = y.Name)
Harsh AthalyeIndia."Nothing is Impossible"
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts
Posted - 2006-08-11 : 10:58:16
You could always invoke the most suitable "Excel" function to do this...ie an implementation of the 'VLookup' function!! Bringing 'SQL' into the equation just complicates matters!
younker1983
Starting Member
3 Posts
Posted - 2006-08-14 : 04:38:29
if i merge the both sheetsin sheet1Name-- custcode -- Prod. --value --year-- a -- 001 -- 24 -- 100 -- 2004-- b -- 002 -- 26 -- 240 -- 2004-- a -- 001 -- 33 -- 120 -- 2004-- a -- 001 -- 21 -- 200 -- 2004-- c -- 003 -- 26 -- 240 -- 2004-- b -- 002 -- 33 -- 120 -- 2004-- d -- 004 -- 24 -- 100 -- 2004in sheet 2Name -- CustCode -- Prod. -- value -- year-- a -- 001 -- 24 -- 100 -- 2005-- d -- 004 -- 26 -- 240 -- 2005-- a -- 001 -- 33 -- 120 -- 2005-- e -- 005 -- 26 -- 240 -- 2005-- a -- 001 -- 21 -- 200 -- 2005-- c -- 003 -- 26 -- 240 -- 2005-- d -- 004 -- 24 -- 100 -- 2005firstly i create the unique values from both sheetsName-- custcode -- Prod. --value --year-- a -- 001 -- 24 -- 100 -- 2004-- b -- 002 -- 26 -- 240 -- 2004-- c -- 003 -- 26 -- 240 -- 2004-- d -- 004 -- 24 -- 100 -- 2004sheet2Name -- CustCode -- Prod. -- value -- year-- a -- 001 -- 24 -- 100 -- 2005-- d -- 004 -- 26 -- 240 -- 2005-- e -- 005 -- 26 -- 240 -- 2005-- c -- 003 -- 26 -- 240 -- 2005then i merge the sheets copy all rows into one single sheetsheet3Name-- custcode -- Prod. --value --year-- a -- 001 -- 24 -- 100 -- 2004-- b -- 002 -- 26 -- 240 -- 2004-- c -- 003 -- 26 -- 240 -- 2004-- d -- 004 -- 24 -- 100 -- 2004-- a -- 001 -- 24 -- 100 -- 2005-- d -- 004 -- 26 -- 240 -- 2005-- e -- 005 -- 26 -- 240 -- 2005-- c -- 003 -- 26 -- 240 -- 2005from this 3rd sheet i want to choose to retrieve only that records which are present in 2004 but not in 2005. in this example i want to retrieve only one record which is b--002-26-240-2004. the name B is the dropout in 2005 year. plz tell me how can i do this i have more than thousands row.