logo
down
shadow

how to create a new database after a trigger fired from a table


how to create a new database after a trigger fired from a table

By : Kamal Deshapriya
Date : November 18 2020, 03:49 PM
may help you . Although this seems a pretty strange thing to do, if you really have to then create an Agent job that simply restores the database from a backup. In the trigger, you could run the job with:
code :
EXEC msdb..sp_start_job @job_name = 'JobName'


Share : facebook icon twitter icon
mysql create a trigger in a database listening to table changes in a different database

mysql create a trigger in a database listening to table changes in a different database


By : user2265066
Date : March 29 2020, 07:55 AM
hope this fix your issue The trigger needs to be in the same schema as the table you are inserting to, but it can access tables in other schemas.
Using your example:
code :
CREATE TRIGGER schema2.triggername
AFTER INSERT ON schema2.the_table
FOR EACH ROW
  INSERT INTO schema1.the_table values (...);
How Do I create a trigger on a table that insert into another database

How Do I create a trigger on a table that insert into another database


By : user3366737
Date : March 29 2020, 07:55 AM
I hope this helps . I have two mySQL db's on called home and the other called zenphoto_live. , Specify a full name for the trigger, e.g. -
code :
CREATE DEFINER = CURRENT_USER TRIGGER zephoto_live.new_images AFTER INSERT ON
...
USE zephoto_live;
CREATE DEFINER = CURRENT_USER TRIGGER new_images AFTER INSERT ON
...
How to create a database user and grant it permission to create trigger for specific table only

How to create a database user and grant it permission to create trigger for specific table only


By : banut
Date : March 29 2020, 07:55 AM
help you fix your problem I'm testing my project and I have to write permissions unit test for one of its components. Unit tests start from creating temporary database and table. I want to write SQL code which creates new user for temporary database and grants it permission to create trigger (single function which component does) just only for temp test table. This user will be used by my component. How can I do this? Any help appreciated. , Try this SQL code. It works for me:
code :
USE [YourDatabase];
CREATE USER YourUser FOR LOGIN YourLogin;
GRANT ALTER ON dbo.YourTable TO [YourUser]
How to create a trigger to populate a table from another table in a different database

How to create a trigger to populate a table from another table in a different database


By : Xpl0s01v3DyN0M173
Date : March 29 2020, 07:55 AM
I wish this helpful for you I am unclear about the logic in your selection but if you want to save a copy of what was just inserted into table1 into a table (table2) on another database, using a trigger, you can try this:
code :
create trigger trig1 on dbo.table1 
after insert as 
insert into database2.dbo.table2 (col1,col2,col3) values    (inserted.col1,           inserted.col2)`
Create a trigger TR1 for INSERT, DELETE triggering event where trigger should be fired if the transactions are performed

Create a trigger TR1 for INSERT, DELETE triggering event where trigger should be fired if the transactions are performed


By : Davies
Date : March 29 2020, 07:55 AM
Any of those help , Please try this You have to add normal DML commands
code :
alter trigger TR1
on Employee 
Instead of Insert,Delete
as
begin
    if (datepart(dw,getdate())=1)
        Raiserror('cannot insert records since today is sunday',16,1)
    else
    begin
        insert into Employee select * from inserted
        delete from Employee where id in (select id from deleted)
    end
end

go
Related Posts Related Posts :
  • FreeTDS working, but ODBC cannot connect
  • How to change datetime format of varchar datatype column
  • Trigger on extended properties? SQL SERVER
  • Database Schema guidance for an app store
  • sql trigger to update based on specific column is updated and if value is equal to 'x'
  • How to descope a local variable in t-sql
  • SQL Server Compact stored procedure with multiple values in 1 input
  • How to validate the ICCID number of a SIM card in TSQL?
  • how to calculate all previous datas sum of a sql column on a date range report
  • How to create view listing all friendship for "friend1,friend2" table in T-SQL and prevent inserting duplicate
  • Sum of multiple column in SQL Server
  • Check month and day lies between two dates
  • How would I configure Effort Testing Tool to mock Entity Framework's DbContext withOut the actual SQL Server Database up
  • While looping through a function, Error: Maximum stored procedure, function, trigger, or view nesting level exceeded (li
  • Collapsing records with adjacent start and end dates
  • SQL Server Management Studio 2008 - Timeout Expired error
  • Insert date from VB to SQL Server
  • How to find what table foreign key is from?
  • Sql Server Nested Inserts possible
  • Deterministic way of getting WeekEnding (Sun) for given date column (for use in computed column)
  • SQL Server, why does one order by query work with a string, but not with an integer?
  • How do I install a SQL Server on the hosted build agent in Visual Studio Online?
  • EXECUTE AS/REVERT within a transaction in SQL Server
  • Distinct 2 field AS one column SQL SERVER
  • How to sort string alphabetically
  • Checking data in one column in a temp table to a column in another table
  • What's wrong with my IF/ELSE? "ELSE: Incorrect syntax near 'ELSE'."
  • CASE CLAUSE IN WHERE CONDITION
  • TSQL - Creating a running total of a column
  • Why am I getting not null here?
  • Why does sp_refreshview raise an exception on views that are not schema bound?
  • EXEC parameters from a SELECT
  • SQL Server Compact connection
  • Star Schema Structure - To many Dimensions
  • sort utf string in sql server with join clause
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org