I have to convert store procedure from that is written in sql server, to mysql procedure. I know the their general differences like AS, GO and ; but still mysql procedure has not the same result as sql server. It is noteworthy that tables and their data are the same. can anyone say other differences between them?
I will thank you if you tell me correct answer in this case
I figure out for using mysql parameters like IN b INT in procedure code, I must use b directly! not #b like sql server
Related
In MS SQL Server, it lets you search across all the stored procedures for the instance of some text. Does this exist in MySQL?
This is useful for trying to understand what the impact of changing the schema would be.
"Show me all the code that involves TableX"
How would you query across all stored procedures?
The procedures are stored in table mysql.proc. The code is in column body.
So you could query:
SELECT db, name, body FROM mysql.proc WHERE body REGEXP '[[:<:]]tablename[[:>:]]'
I have a stored procedure looking like this:
SELECT
nTransactionId
,strInstrument
FROM dbo.Deals
I've read that for SQL Server 2012 I can use sp_describe_first_result_set, but is there any alternative for SQL Server 2008?
When I say I want the column names I mean nTransactionId and strInstrument. Even if the query doesn't return any result.
Many thanks!
For that purpose I mostly use :
SET FMTONLY ON;
Returns only metadata to the client. Can be used to test the format of
the response without actually running the query.
Have a look here: Sql Server SET FMTONLY (Transact-SQL)
This is what DataSet designer is using for example in order to get the parameteres of a procedure.
I need to display the entire code in a stored procedure using SQL query when i have the name and db of the stored procedure
sp_helptext seems like it might do the trick for you. Syntax here.
Try this:
SELECT [definition]
FROM sys.sql_modules
WHERE object_id = OBJECT_ID('dbo.YourStoredProcNameHere')
Works in SQL Server 2005 and newer.
I created a stored procedure which ran successfully but I can't seem to find the procedure in the usual place within the database and I can't execute the procedure in Excel but I can drop the procedure.
I am confused.
I have written many stored procedures and never had this problem. Thanks in advance.
Sounds like something I've done before: inadvertently added the stored proc to the master database rather than the database I thought I was working in.
Check the master database under System Databases.
To prevent this in the future, you may want to consider adding a use dbname statement in the script.
I am writing a SQL Server stored procedure for the first time and am unclear on how I can "save" my stored procedure so that it appears under Programmability, Stored Procedures in the Object tree.
The CREATE PROCEDURE procedureName statement creates the procedure.
You just need to execute it once and it will save the procedure to your database.
Make sure to select the correct database you want to save the procedure to, either by selecting it in the top left hand corner of SQL Server Management Studio, or by putting the following at the top of your code:
USE databaseName
Also note, if there are any syntax errors, it won't "save" the procedure.
While you are learning SQL Server and Management Studio, you may find it very helpful to become familiar with the built-in templates for creating everything from databases to tables to stored procedures and more. You locate the templates in Template Explorer under the View menu.
The first example in this walk-through with screenshots shows how to use the template for creating a stored procedure. That template includes a placeholder for the schema name (often just dbo).
You will also want to include a USE statement to make sure that the stored procedure is created in the correct database.
In addition to helping you to learn proper coding practice, using these templates can be a real time-saver and help you to avoid typos and syntax errors even after you becomem proficient in SQL.
And when you get really good at it, you can create your own templates.
Edit: Here is a very basic CREATE PROCEDURE statement:
USE MyDatabase
GO
CREATE PROCEDURE dbo.MyProcedure
AS
SELECT FirstName, LastName, Address, City
FROM Customers
ORDER BY LastName
GO
After you run that, you can run this line to check that the procedure has been created and that it is working correctly:
EXEC dbo.MyProcedure
you just use a create statement:
http://msdn.microsoft.com/en-us/library/aa258259(v=sql.80).aspx