What is the best way to test MySQL stored procedures? How do you test stored procedures with output parameters in the MySql GUI?
My standard method is to create SQL scripts that create the test data, call the stored procedure, and automatically verify the post-conditions of the stored procedure. You could use the MySQL Query Browser to write/run the scripts.
HTH -
Chris
Related
Using changesets that call SQL Server scripts, there are some identical scripts which perform some work where the only difference is a version number (string).
To consolidate code, a stored procedure was considered which would take a parameter (version string).
How can a stored procedure, with a parameter, be called from a changeset? I've seen one example for Oracle but it doesn't seem to work for SQL Server.
Couldn't figure out how can we use a stored procedure as source dataset in Azure Data Factory copy activity? Is there a way to have a stored procedure as the source data in a copy data task?
Yes, ADF supports to read data from a stored procedure in Copy activity. See the below picture, we use an Azure SQL dataset as example, click the stored Procedure checkbox, select the stored procedure script in your database then fill the parameter if needed. This doc provides more information. Thanks.
Be careful as when using the stored procedure source with 'auto create' table set a schema infer step is performed which executes the code in the stored procedure in a VERY peculiar way that can cause pipeline errors - especially if you have any dynamic SQL and/or conditions in the stored procedure code! There is a work-around I have discovered which allows the stored procedure to be written in a fully functional way without breaking the pipeline. I will write a separate article on it perhaps.
Can I write a SQL script to dynamically create all stored procedures and views from one database to another?:
I have 2 instances of MyDatabase
1 MyDatabase instance on ServerX
1 MyDatabase instance on ServerY
I'd like to write a SQL script which does the following:
Drop all stored procedures and views on ServerY
Generate CREATE statements for all stored procedures and views on ServerX
Execute those CREATE statements on ServerY, so all stored procedures and views on ServerY match those on ServerX
I'm sure this can be done but can anyone here describe a way to go about doing this?
There is an easier way to do this - SQL Server can script the creation of the objects for you into a single *.sql file. You then just run that script on the other server. You can even have it include the data from the existing database. For a detailed walk through, see: https://dzone.com/articles/generate-database-scripts-with-data-in-sql-server
Why? SQL Server has all this built in for you
Once all your SP and views are on Server.. Right click on your database and click Tasks > Generate scripts. SQL Server Management Studio is able to generate the CREATE scripts for you, which can be done on SP, views and more.
Then you simple copy this script and execute it on ServerX server/database.
BUT if you need it to be automated you should use powershell to simulate this task. Doing this in a SQL script isn't the best solution.
Create a link from the server X to the server Y and select, assume server x for the primary.
How do I extract DDL, Stored Procedures (SP) and other database scripts from Sybase ASE.
Look into the ddlgen utility included with sybase, ususally found in the Sybase Central directory, or the $SYBASE/ASEP/bin. This should be able to generate scripts to create all of the database objects including user-defined datatypes (UDD), indexes, stored procedures, etc.
You can use sp_helptext to show the DDL.
I want to know that is there any way through which I can execute all my stored procedure at a time.
Presently I am executing each stored procedure using exec "Stored Procedure name" command.
And I have more than 200 stored procedure to be executed on my database.
Is there any easy way out to execute all these stored procedure at a single time as it is difficult for me to keep a track of them?
I suggest you write a stored procedure which calls the other ones.
Put all stored procedures inside a stored procedure,
CREATE PROCEDURE CallAllProcedure
AS
BEGIN
CALL Proc1
CALL Proc2
END
Assuming that you are using Query Analyzer, just put a GO in between all those stored proc and run script.
If you want to execute them all in parallel you could create a SQLJob and schedule them all to execute at the same time. Link below is general usage of SQL Jobs.
http://msdn.microsoft.com/en-us/library/ms190268.aspx
you can select all stored procedure names from sys.objects table querying type='P'. After you can use cursor for every stored procedure name to execute. But how about stored procedures with parameters? you must provide parameter values as well to avoid from errors.
You can use Service broker to do this async but I dont think it is a great idea to run 200 stored procs at the same time unless you are sure there will not be any contention on the DB