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  | 
                             
                            
                                    | 
                                         bpuccha 
                                        Starting Member 
                                         
                                        
                                        34 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2012-06-14 : 15:02:00
                                            
  | 
                                             
                                            
                                            | Hi,Do we have for loop in sql server 2000? How to do the below scenario in sql server Table1:name id amt----------vbjh 1 1000guhu 2 3000bjkh 4 1000Code in Orcale:beginfor i in (select id from table1)loopdbms.output('i')end loopend | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     visakh16 
                                    Very Important crosS Applying yaK Herder 
                                     
                                    
                                    52326 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-14 : 15:42:28
                                          
  | 
                                         
                                        
                                          you just needSELECT id FROM table1 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     tkizer 
                                    Almighty SQL Goddess 
                                     
                                    
                                    38200 Posts  | 
                                    
                                      
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     bpuccha 
                                    Starting Member 
                                     
                                    
                                    34 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-14 : 15:53:51
                                          
  | 
                                         
                                        
                                          | My scenario is like thisI have a property table with the below detailsp_no  t_no r_no r_p------------------00001  001 2    PQ00001  001 4    PQ00001  001 1    ON00001  001 3    ON00001  001 5    ONI have 9 queries , I created a table valued function to return the data from all these 9 queries.For r_no's 2 ,4 i have to run the query1 and isnert the data into a table, again for 2 and 4 run the query 2 and isnert the data into a table....so on again 2 and 4 run the query 9 and isnert the data into a tableIn order to execute Query1 i have so many if and else conditions based on the if and else condition the query may change slightly.Once I run all the queries fr=or r_no 2 and 4 , again i have to repeat the same thing from r_no's 1,3,5The order of insertion is important here...How to do this in sql server 2000 ?  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     visakh16 
                                    Very Important crosS Applying yaK Herder 
                                     
                                    
                                    52326 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-14 : 17:09:39
                                          
  | 
                                         
                                        
                                          | are conditions for groups different? why do you need separate queries for each?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     bpuccha 
                                    Starting Member 
                                     
                                    
                                    34 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-06-15 : 09:22:34
                                          
  | 
                                         
                                        
                                          | Yes..The conditions will be different for each group and queries also differs for each group...  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |