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  | 
                             
                            
                                    | 
                                         mikeallenbrown 
                                        Yak Posting Veteran 
                                         
                                        
                                        72 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2015-04-09 : 15:40:46
                                            
  | 
                                             
                                            
                                            | I see how I can generate a CREATE TO script file with a table's data & schema. Is there a way to generate this file but only specific rows?? ...like generate data & schema where clientid = 5001?ThanksMike BrownITOT Solutions, Inc.SQL Server 2012Alpha Five v3 (12) | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     gbritton 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    2780 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-04-10 : 08:39:10
                                          
  | 
                                         
                                        
                                          | just one table?  1. script as create table to file2. write your own query to generate the insert into statement(s) and add to the file from the first step.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     Kristen 
                                    Test 
                                     
                                    
                                    22859 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-04-12 : 07:45:51
                                          
  | 
                                         
                                        
                                          Couple of other ways:Copy the database and delete everying which is not clientid = 5001If we are talking a lot of data then the INSERT script will be slow.  Alternative might be to create a new database and:SELECT *INTO NewDatabase.dbo.MyTableFROM MyTableWHERE clientid = 5001 Or, again if a lot of rows, export using XML and write a routine to import from XML.  Or could use SSIS.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |