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  | 
                             
                            
                                    | 
                                         hulan 
                                        Starting Member 
                                         
                                        
                                        1 Post  | 
                                        
                                        
                                            
                                            
                                             Posted - 2012-05-27 : 07:17:40
                                            
  | 
                                             
                                            
                                            | I got a Project from the University. It needed to create multiple Login Account for Student in differend Database. I decided to start mit M SQL Server 2008R. If I do it in Microsoft SQL Server Management Studio I can Create Login with this Statement: CREATE LOGIN Login_nanem WITH PASSWORD N 'password' but It post to be more then 80 student every term and they don't want create student Loging one by one. it needed to be automated!! I did so far this: I got a textfile (StudentID, Lastname, Firstname) I imported it with SQL BULK INSERT into Server Management Studio as Table Studentlist and used CURSOR get row by by row.I wanted use Create Login statement in while loop with vriable as login_name::: It is not working using variable in this statement: CREATE LOGIN variable WITH PASSWORD N 'password'.Hope I explain myself more less undestandable!!!Any help will very appreciated. Hint and anything helps me move forward. thanks | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     jeffw8713 
                                    Aged Yak Warrior 
                                     
                                    
                                    819 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2012-05-27 : 11:18:52
                                          
  | 
                                         
                                        
                                          | You need to use dynamic SQL and build the string to be executed.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |