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  | 
                             
                            
                                    | 
                                         m.i.d. 
                                        Starting Member 
                                         
                                        
                                        2 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2012-08-14 : 12:06:30
                                            
  | 
                                             
                                            
                                            | I want to script SQL Server objects programmatically [say, delete (DROP) all FKs, then change keys, and restore (CREATE) FKs] with SMO Scripter class.I found [url=http://www.yaldex.com/sql_server/progsqlsvr-CHP-12-SECT-1.html]an article on the Web[/url], but...Please see [url=https://dl.dropbox.com/u/60064807/SMOQuestion.jpg]the image[/url] and help me to compile ~20 line long C# program.Thanks.I am not a rookie. No. | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     sunitabeck 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    5155 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-08-14 : 13:28:08
                                          
  | 
                                         
                                        
                                          Add a using Microsoft.SqlServer.Management.Sdk.Sfc; or usescripter.Script(new Microsoft.SqlServer.Management.Sdk.Sfc.Urn[] { db.Urn });  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     m.i.d. 
                                    Starting Member 
                                     
                                    
                                    2 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-08-15 : 08:51:54
                                          
  | 
                                         
                                        
                                          | Thanks, sunitadeck. It works. Something seems to change since SQL Server 2005.Case closed.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |