Trigger to soft delete a row from the table in SQL
Hi,
I want to write a Trigger in SQL 2005 which will soft delete a perticular row means it will update the STATUS field of table from ACTIVATED to DELETED .
the row shpuld not get deleted.
- If you need clarification, ask it in the comment box above.
- Better answers use proper spelling and grammar.
- Provide details, support with references or personal experience.
Tell us some more! Your answer needs to include more details to help people.You can't post answers that contain an email address.Please enter a valid email address.The email address entered is already associated to an account.Login to postPlease use English characters only.
Tip: The max point reward for answering a question is 15.
Owing to the small size of MS SQL database repair utility download this program can be got immediately therefore there is a chance to avoid the losing of time and trigger the analysis and Microsoft SQL Server 2005 repair database as soon as the damage occurs. https://www.sqlserverrepairtoolbox.com/
Known as the leading solution provider in the field of data recovery and data conversions, the company has created a niche for another efficient tool known as SQL Server Repair Toolbox. The MS SQL repair tool reads *.mdf and *.ndf files and saves data, structure, links, etc. as SQL scripts or exports directly to Microsoft SQL Server through direct connect. read more details SQL Server Repair Toolbox
You can restore corrupt and delete SQL database file in few steps for MySQL Restore Toolbox. With this software you can also recover triggers, keys, indexes and table. Software support multiple MDF file recovery option. Software is supported by all Windows operating system. Get more ideas and download free trial version from -http://www.filerepairforum.com/forum/databases/databases-aa/mysql/1162-dump-mysql-database-file-is-error
Use SQL Server Repair Kit. A convenient, reliable and ultimately efficient MS SQL database repair tool for system administrators, developers and database experts. Best in class performance and outstanding usability for users with and without experience.
David, what you're looking for is pivot table functionality. Unfortunately, that is not a built-in feature for MySQL (it is for SQL Server 2005/2008). Not knowing your table structure, or the size/number of rows/columns, I found the following link to be most helpful example: MySQL Pivot Table Example
You need to have two tables. One table for the reservation (each reervation having a primary key) and one table to store the people "linked" to that reservation. In the second table, each person will be on a row and one column in your second table would refer to the first (reservation) table in a one-to-many relationship. Read into database design and this will make sense. This can all be done in ADO.NET.
Create Trigger trigger_name // "trigger_name" : Give name to the trigger on table_name // "table_name" : name of the table on which trigger has to created for Update as
A trigger is a special kind of stored procedure that automatically executes when an event occurs
in the database server. A trigger is really an event handler.
SQL Server allows users to create triggers (event handlers) for 3 types of events:
DML Event - Occurs when a DML (Data Manipulation Language) statement: INSERT, UPDATE or DELETE,
is executed.
DDL Event - Occurs when a DDL (Data Definition Language) statement: CREATE, ALTER, or DROP,
is executed.
Logon Event - Occurs when a user logins to the Server.
There are 3 different types of triggers (event handlers) based on the types of events they are triggered by:
DML Trigger - Executes in response to a DML event.
DDL Trigger - Executes in response to a DDL event.
Logon Trigger - Executes in response to a logon event.
Generally database updates either require a commit to have the database perform the appropriate checking and actually flag the rows as part of the database. That Commit can occur in two ways -- some databases can be setup with an auto commit or auto rollback when the database is disconnected. The first means the programmer needs to do nothing. The second means if the programmer does not commit the updates are backed out of the database. To commit is generally considered bad because if there are any data errors partial transactions and logically inconsistent contents can exist in a database. For example entering an order for merchandise requires a single header row to identify the customer and multiple items rows to indicate what was ordered. If the third item record added to an order had an error and the application did not rollback and the database auto committed and incomplete order with only two items would be saved in the database. Traditionally databases with an automatic action at shutdown are set to rollback to assure such partial information is not saved. Even with auto rollback good programs detect errors and rollback themselves and allow users to continue.
The net result of the above is the probability that if the inserts actually occurred as you believe the there was a missing commit to confirm their addition to the database. and an automated rollback kept them from being completely added to the database. Another alternative is that the insert was not error checked in the program code and it failed meaning despite the program counter claiming rows were inserted in fact they were not.
×