phpMyAdmin dynamic sql - how to use? - sql

Does dynamic SQL work in phpMyAdmin?
I tried the most basic examples from http://www.youtube.com/watch?v=MiAwOoelu9k
For instance, each of these throws an error (tried separately):
EXEC ('SELECT data FROM table')
EXEC sp_executesql N'SELECT data FROM table'

I found the answer in multiple Stackoverflow streams (listed below). It depends on the version of phpMyAdmin, which needs to be v3.5.2.2 or higher. This is because Dyanamic SQL is part of a STORED PROCEDURE. Older versions of phpMyAdmin allow you to CREATE a STORED PROCEDURE, but the ability to CALL a STORED PROCEDURE within phpMyAdmin requires version 3.5.2.2 or higher. (Source: is it possible to run a stored procedure from within phpmyadmin 3.4.10.1?)
For those using an older version of phpMyAdmin who need to use Dynamic SQL, an alternative is Workbench (http://www.mysql.com/products/workbench/)
For those using phpMyAdmin version 3.5.2.2 or higher, to CREATE and CALL a STORED PROCEDURE, here are posts of other users:
How to write a stored procedure using phpmyadmin and how to use it through php? How to write a stored procedure using phpmyadmin and how to use it through php?
MySQL procedure not getting created/working using phpmyadmin mysql procedure not getting created/working using phpmyadmin
How do I view my stored procedures in phpMyAdmin? How do I view my stored procedures in phpMyAdmin?
I created several stored procedures in phpmyadmin, how to call them using an sql query? I created several stored procedures in phpmyadmin, how to call them using an sql query?

Related

Execute sql server stored procedure from changeset

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.

SQL Server 2012 XP_DELETE_FILE is Missing

I have inherited an SQL Server 2012 database that has a stored procedure which references a master database stored procedure called XP_DELETE_FILE. The stored procedure is failing because the XP_DELETE_FILE is not present in the master database. It seems to be an undocumented procedure and I don't know where I can source it. Any suggestions on a how to resolve this issue?
Thanks,
F.
You are attempting to access the system extended procedure using the dbo schema. This was changed some time ago to use the sys schema.
Change this:
EXEC master.dbo.xp_delete_file ...
To this:
EXEC master.sys.xp_delete_file ...

Rebuild Execution Plan In Sql Server 2012 on Stored Procedures Using Specific Table

I have couples of stored procedure's that are using Product table,I want to re-build the execution plan of all the stored procedure's that are using specific table Product?Kindly guide me,how to achieve this?I am using sql server 2012.
You can do this in following way:
USE YourDatabaseName;
GO
EXEC sp_recompile N'Product';
GO

SQL Server 2005 How to ignore errors during Create Procedure

I need to create a Stored Procedure in SQL Server 2005. Somewhere in the procedure, I have to join to a table which does not exist in the test environment but in the live environment (in a database in a linked server). I will not run the procedure in the test environment, but I need it to exist in order to create the ORM code in the application.
Naturally, SQL Server raises the error "Could not find server 'xxx' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedur sp_addlinkedserver to add the server to sys.servers.". However, I know that I can't add this server to the test environment, as it is not accessible from outside.
So, my question is, how can I create my stored procedure by ignoring the errors? Is there a way for it?
This is an old thread, but if other people are having the same problem, here's another solution:
You can have your server via text and the procedure will pass.
create proc test
as
declare #myserver varchar(50) = '[myserver\myinst]'
exec('select * from '+#myserver+'.dbo.table')
This way, the proc will compile on any environment, but will only run successfully on production
If you are certain that everything is correct and the procedure will work fine in live environment then create a fake linked server using sp_addlinkedserver.
What I mean is, if procedure body contains a linked server named test_linked and if it's not found then it will throw error.
Use sp_addlinkedserver and create a fake linked server named test_linked pointing to your test environment or even live environment. that will solve the issue cause it will try to check whether a linked server named test_linked does exist in sys.servers or not but unless you are running the procedure the actual linked server will not be accessed (AFAIK).
As Aaron Bertrand have mentioned in comment, Going by synonym would be a much cleaner approach though.

Stored Procedure stopped working

I have a stored procedure that I'm positive of has no errors but I recently deleted the table it references but imported a backup with the same name exactly and same column settings (including identity) that the previous one had but now it doesn't work.
Is there any reason that having deleted the table but importing a new would break the stored procedure?
BTW: Running Microsoft SQL Server Express Edition w/ IIS.
you can try to recompile the stored procedure with:
exec sp_recompile YourProblemTableNameHere
this will recompile all procedures that use the YourProblemTableNameHere table. But that is just a guess based on the very limited info given.