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.
    
        
            
                
                    
                        
                            
                                | Author | 
                                
                                 Topic  | 
                             
                            
                                    | 
                                         annas 
                                        Starting Member 
                                         
                                        
                                        36 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2008-04-08 : 11:39:56
                                            
  | 
                                             
                                            
                                            Haii...What i want to do is to select a data from other table and insert into another table. I using below code, but an error occur "There is an object name Bill in database".SELECT OrderID, TableID INTO BillFROM OrdersWHERE (OrderID =(SELECT MAX(OrderID) FROM Orders))  | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     harsh_athalye 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    5581 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-04-08 : 11:44:33
                                          
  | 
                                         
                                        
                                          | It means table "Bill" already exists in the database. You should check existence of table before running the query.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     annas 
                                    Starting Member 
                                     
                                    
                                    36 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-04-08 : 12:05:31
                                          
  | 
                                         
                                        
                                          | if i want to insert a data into table already exist can it be done  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     harsh_athalye 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    5581 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-04-08 : 12:09:44
                                          
  | 
                                         
                                        
                                          | In that case, don't use SELECT..INTO, use INSERT INTO TABLE..SELECT statement.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     annas 
                                    Starting Member 
                                     
                                    
                                    36 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-04-08 : 12:27:45
                                          
  | 
                                         
                                        
                                          | I using below code, but have error, can u identified itINSERT INTO Bill(OrderID, TableID)FROM Orders WHERE OrderID =(SELECT MAX(OrderID) FROM Orders)  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     harsh_athalye 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    5581 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2008-04-08 : 12:37:32
                                          
  | 
                                         
                                        
                                          | INSERT INTO Bill(OrderID, TableID)Select OrderID, TableID FROM Orders WHERE OrderID =(SELECT MAX(OrderID) FROM Orders)Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |