I created a database then I create a procedure. When I want to alter this database, I got an error while altering this database says:
create/alter must be the first statement in a query batch
If you have more than one statement to run use 'GO' command:
alter database xyz ...
GO
INSERT INTO myTable() ...
GO
etc
Related
I'm doing db data migration in MySQL.
I have two tables - source (T1) & destination (T2).
I created one insert ignore script to migrate data from T1 to T2. during script run some record might have failed. So I want to capture these failed records in another table and publish the report out of it
Through a stored procedure I'm able to capture errors and inserted to error table.
But as I asked not use stored procedure so is there any alternative way to capture failure records and insert to error table
Thanks in advance
You can log in to MySQL and specify your error log file:
mysql -u user -p 2> errors.log
Once you are logged in, run the commands that you have and all errors will be written into the file.
such as one of the file content is:
INSERT INTO `de_admin` VALUES('1','10','admin','f297a57a5a743894a0a4','admin','','','','1547032874','127.0.0.1');
I want to know how can I execute all these files' sql commands into my MySQL database?
I mean is there a simple way to do this?
I have 3 triggers in mysql. Is there a way to create sequence on running the triggers like sql server?
Can we run the SQL dump command through a stored procedure/Trigger. I have to create a database on fly when certain events happen in the table.
I have achieved it on mysql command prompt or by workbench, however need a way to do it through procedure or trigger.
I am running Microsoft SQL Server 2012 and am attempting to run an openquery delete command into a MySQL database:
delete openquery(MyLinkedServer, 'select * from table_to_delete_from');
This works, however is utterly, painfully slow to the point that it is unviable. The dataset involved is far too large, and doing the above requires that all of the MySQL data to be deleted must be fetched over VPN to the MSSQL server.
When running this command directly from the MySQL server, it is observed to be over 5x faster, which is viable.
How can I invoke a delete command from MSSQL over to the MySQL linked server without having to copy the datasets? Perhaps running a stored procedure of sorts on the MySQL side? Does that work with openquery?
Try this:
exec ('delete from table_to_delete_from') at MyLinkedServer
another case for SSIS, whenever i need to communicate to MYSQL. and insist to have truncate process on MYSQL table. i provide the procedure like below, :
CREATE PROCEDURE [dbo].[Usp_DeleteDynamicTable] #sourceTable nvarchar(max)
AS
BEGIN
DECLARE #SQL nvarchar(max)
SET #SQL='truncate table '+ #sourceTable
exec (#SQL) at MYSQL --MYSQL is my linked server names
END