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  | 
                             
                            
                                    | 
                                         aroraaj 
                                        Starting Member 
                                         
                                        
                                        2 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2014-08-08 : 14:50:11
                                            
  | 
                                             
                                            
                                            | Hello, I have a question regarding SQL Server. Is there anyway to find out what was the last query used for a specific database? | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     MichaelJSQL 
                                    Constraint Violating Yak Guru 
                                     
                                    
                                    252 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2014-08-08 : 15:17:09
                                          
  | 
                                         
                                        
                                          | Are you looking for something like this?  SELECT top 1 *  from  master.dbo.sysprocesses r 	CROSS APPLY sys.dm_exec_sql_text (r.sql_handle) sq  WHERE spid != @@spid  ORDER BY last_batch  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |