| Author | Topic | 
                            
                                    | snow12Yak Posting Veteran
 
 
                                        74 Posts | 
                                            
                                            |  Posted - 2011-11-02 : 12:28:58 
 |  
                                            | Hello:I think my previous post not clear enough. Here is my problem.I have table: Name id   name   time    term    test12   Jean     1        1       012   Jean     2        2       012   Jean     3        3       012   Jean     4        4       012   Jean     5        5       012   Jean     6        6       012   Jean     7        7       012   Jean     8        8       012   Jean     9        8       012   Jean    10       11       012   Jean    11       11       0 32   QADF     1        1       032   QADF     2        2       032   QADF     3        5       032   QADF     4        5       032   QADF     5        5       032   QADF     6        6       032   QADF     7        7       032   QADF     8        8       041   RTHF     1        1       041   RTHF     2        2       041   RTHF     3        5       041   RTHF     4        5       041   RTHF     5        5       041   RTHF     6        6       041   RTHF     7        7       041   RTHF     8        8       041   RTHF     9        8       0need to update column: time and term where id = 12, 32, 41 ......212.I have several hundred IDbase on following excel data needed to be update time and test column. time    term    test	id   name1        1         02        2         03        3         04        10        05        11        07        7         08        8         09        8         010       11        011       11        012       11        0 There is any efficient way work out it? Thank you very much!  |  | 
       
                            
                       
                          
                            
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2011-11-02 : 13:39:07 
 |  
                                          | something like UPDATE tSET t.time=x.time,t.test=x.testFROM table tINNER JOIN (SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=excel file path here', Sheetname$);)xON x.id = t.idand x.term = t.term------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |  
                                          |  |  | 
                            
                       
                          
                            
                                    | snow12Yak Posting Veteran
 
 
                                    74 Posts | 
                                        
                                          |  Posted - 2011-11-02 : 15:14:47 
 |  
                                          | Thanks for the reply.So I have to make several hundred excel files for each id first.For example; The template time    term    test	id   name1        1         02        2         03        3         04        10        05        11        07        7         08        8         09        8         010       11        011       11        012       11        0for each id id = 12time    term    test	id   name1        1         0	12   Jean2        2         0	12   Jean3        3         0	12   Jean4        10        0	12   Jean5        11        0	12   Jean7        7         0	12   Jean8        8         0	12   Jean9        8         0	12   Jean10       11        0	12   Jean11       11        0	12   Jean12       11        0	12   Jean id = 32time    term    test	id   name1        1         0	32   QADF 2        2         0	32   QADF 3        3         0	32   QADF 4        10        0	32   QADF 5        11        0	32   QADF 7        7         0	32   QADF 8        8         0	32   QADF 9        8         0	32   QADF 10       11        0	32   QADF 11       11        0	32   QADF 12       11        0	32   QADF  ID = 41time    term    test	id   name1        1         0	41   RTHF 2        2         0	41   RTHF 3        3         0	41   RTHF  4        10        0	41   RTHF  5        11        0	41   RTHF  7        7         0	41   RTHF  8        8         0	41   RTHF 9        8         0	41   RTHF  10       11        0	41   RTHF  11       11        0	41   RTHF  12       11        0	41   RTHF Is any way no need to make several hundred excel files but still could update table only based on one template file above?Thank you very much! |  
                                          |  |  | 
                            
                       
                          
                            
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2011-11-03 : 04:25:22 
 |  
                                          | why should you need separate excel files? isnt it matter of putting all of them in same excel with new column id to indicate ID value. Use it also in join condition to make sure you update row with correct id.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |  
                                          |  |  | 
                            
                       
                          
                            
                                    | snow12Yak Posting Veteran
 
 
                                    74 Posts | 
                                        
                                          |  Posted - 2011-11-03 : 12:23:37 
 |  
                                          | Visakh:Thank you very much for response.So first, I need to repeatly put hundreds id on this template. It is time Consuming to make hundreds id repeat the same on excel. Is there any efficient way to dynamicallyinput id?Template:time    term    test      name    id  1        1         0      RTHF2        2         0      RTHF   3        3         0      RTHF4        10        0      RTHF5        11        0      RTHF7        7         0      RTHF8        8         0      RTHF9        8         0      RTHF10       11        0      RTHF11       11        0      RTHF12       11        0       RTHFid = 12, 32, 41 .......55,76,123,456As always, your help is highly appreciated. |  
                                          |  |  | 
                            
                       
                          
                            
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2011-11-03 : 12:31:05 
 |  
                                          | sorry whats the significance of this sequence?12, 32, 41 .......55,76,123,456------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |  
                                          |  |  | 
                            
                       
                          
                            
                                    | snow12Yak Posting Veteran
 
 
                                    74 Posts | 
                                        
                                          |  Posted - 2011-11-03 : 14:44:04 
 |  
                                          | Thanks for the response again.It is just random id number, not sequence at all, but there is several hundred id |  
                                          |  |  | 
                            
                       
                          
                            
                                    | snow12Yak Posting Veteran
 
 
                                    74 Posts | 
                                        
                                          |  Posted - 2011-11-03 : 14:47:29 
 |  
                                          | I have a separate excel sheet for those several hundred id. |  
                                          |  |  | 
                            
                       
                          
                            
                                    | viol-8-rStarting Member
 
 
                                    4 Posts | 
                                        
                                          |  Posted - 2011-12-08 : 16:37:17 
 |  
                                          | Hi Visakh16,I see you have contributed a lot to this issue. I have a strange issue. I am following your script and it runs fine on my sandbox but produces an error on production server with error 7203 whereas all the necessary drivers are installed. Any idea why would it do that?viol-8-r |  
                                          |  |  | 
                            
                       
                          
                            
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2011-12-09 : 00:21:54 
 |  
                                          | whats the error you're getting?is OPENROWSET enabled on production box?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |  
                                          |  |  | 
                            
                       
                          
                            
                                    | viol-8-rStarting Member
 
 
                                    4 Posts | 
                                        
                                          |  Posted - 2011-12-09 : 14:45:15 
 |  
                                          | Yes , openrowset is enabledhere is my queryUPDATE ISET I.itemdesc = T.itemdescFROM iv00101 IINNER JOIN OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=D:\desc.xls;', 'SELECT itemnmbr, itemdescFROM [sheet1$]') TON I.itemnmbr = T.itemnmbr where I.ITEMNMBR = '01-03-0136'and the error messageOLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Unspecified error".Msg 7303, Level 16, State 1, Line 1Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".viol-8-r |  
                                          |  |  | 
                            
                       
                          
                            
                                    | visakh16Very Important crosS Applying yaK Herder
 
 
                                    52326 Posts | 
                                        
                                          |  Posted - 2011-12-10 : 08:00:13 
 |  
                                          | is the excel sheet kept open by somebody?also dont use any spaces,line feed characters etc in OPENROWSET statement------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |  
                                          |  |  | 
                            
                            
                                |  |