Introduction Sometimes we need to track or find which user has DROPPED the table(s) from the Database. In this article, we will discuss the possible ways to track this situation.
Sometimes we need to track or find which user has _DROPPED _the table(s) from the Database. In this article, we will discuss the possible ways to track this situation.
I have a table already in my Database,
SELECT [StudentId], [FirstName], [LastName] FROM [StudentManagementSystem].[Students].[StudentDetails]
Fig 1. Results
Now I am going to apply the Drop Statement to drop the table.
DROP TABLE [StudentManagementSystem].[Students].[StudentDetails]
Now the table is dropped, and if we run the SELECT statement for the above table, we will get an error as,
Fig 2. Invalid object Name
The first option is by using the fn_dblog() function. fn_dblog() is undocumented functions in SQL Server. This function give the transaction logs records in the active part of the transaction log file for the current database.
SELECT [Transaction Id], [Transaction Name], [Begin Time], SUSER_SNAME ([Transaction SID]) AS [User] FROM fn_dblog (NULL, NULL) WHERE [Transaction Name] = 'DROPOBJ' GO
Fig 3. List of Users who has dropped the tables
When we run the above statements in the respective Database, it will list the results of users and the tables dropped. The result column Transaction SID holds the user name.
SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.
This is part 3 of “MS SQL Server- Zero to Hero” and in this article, we will be discussing about the SCHEMAS in SQL SERVER. Before getting into this article, please consider to visit previous articles in this series from below.
Debug SQL stored procedures and develop your SQL database project with dbForge SQL Complete, a new add-in for Visual Studio and SSMS. When you develop large chunks of T-SQL code with the help of the SQL Server Management Studio tool, it is essential to test the “Live” behavior of your code by making sure that each small piece of code works fine and being able to allocate any error message that may cause a failure within that code.
The article provides a thorough guide to SQL Server graph databases with their advantages and downsides, cases of use and useful comparisons. Would SQL Server graph database features fit your next project? While you may not know the definitive answer right now, you might be wondering, “What problems does it solve?”.
This article provides an outlook on various types of subqueries in SQL such as select or other T-SQL statements and caveats when using them.