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
I have a table called tbl_test:
test_id, int, (Primary Key)
test_A, int
test_B, int
test_C, int
test_updated, int
Basically, I want the value of test_updated to be 0 if test_A, test_B and test_C are all 0. And the value of test_updated to be 1 if any of test_A, test_B or test_C are set to 1...
Ok, thanks, I thought that Triggers may be a solution.
I've been googling them for the past hour.
Does anyone have experience of SQL triggers and could show me what I need to do in order to get this to work?
In my SQL Server database, I want a new field in my table called something like 'UPDATED'.
I want this to be defaulted to FALSE. If fields x, y or z are set to TRUE then I want the value of UPDATED to be changed to TRUE as well. And then, if x, y and z are ALL changed to FALSE, then the value...
Hi,
I'm trying to use a linked table from Access 2003 to SQL Server 8.0.
It's a link using a ODBC connection, and it worked fine when there were just a few records in the remote table.
Now there are over 2000 records and I'm getting these errors:
"ODBC--call failed"
and
"cannot generate SSPI...
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.