CREATE TRIGGER userDelete ON tbl_test
FOR DELETE
AS
INSERT INTO tbl_test1 (test_A) ((SELECT test_A FROM Deleted))
I managed it with this.
Thanks for your guidance SQLSister!
I couldn't get it to work with using "Select * From Deleted", but I managed to get a simple example working by using the code below:
CREATE TRIGGER dbo.userDelete ON tbl_test
FOR DELETE
AS
DECLARE @test_A AS varchar(50)
SET @test_A = (SELECT test_A FROM Deleted)
INSERT INTO dbo.tbl_test1...
Ok, I'm very new to triggers so please excuse my ignorance.
I want the following to happen:
- user deletes row from a database
- row gets inserted into a backup table
Is this possible with a Delete trigger?
Basically a client wants rows to be saved in another table when they delete (so they...
A webform written using PHP was meant to send out emails via SMTP. However the port was set to 30 rather than 25 and therefore the emails were never sent.
Is there any hope of retrieving the emails (the data inside - not just what is stored in the logs, i.e. who sent, where, and when)? Or am...
Hi,
I have a data table with shop products in it.
I want to order the data on the 'size' column.
This can be shoe size (9, 10, etc) or it could be shirt size (Large, Medium, etc).
When I order by alphanumeric, the shoe size list looks wrong as it shows this:
10, 10.5, 11, 11.5, 6, 7, 8, 9...
Hi,
I have a popup window, which asks a user to tick 2 tickboxes in order for them to download a zip file.
Once they have ticked the boxes, the page redirects to the zip file which downloads no probs.
The 'problem' is that the popup remains. I want to close this popup automatically, but I...
Hi everyone.
Our SQL Server has stopped twice in the last week. I restart it and everything starts working okay again.
When it 'stops', I get this error when I try and use a website that uses the SQL Server database:
[Microsoft][ODBC SQL Server Driver][DBNETLIB]General network error. Check...
Ok,
the goalposts have been moved again by my client.
I now need test_updated to be the opposite of the other columns. i.e. when test_A, test_B and test_C ALL equal to 0, test_updated must be 1. And if any of them equal 1, then test_updated = 0.
I hope you understand me!
Wicked.
Thanks, that worked fine.
Although I've made a bit of a cock up. The field type's of test_a, test_b, test_c and test_updated should be BIT instead of INT! Your code stops working when I make these changes to my table. Can it be tweaked so it will work with BITs rather than INTs?
Thanks
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.