# New to MySQL -- convert MSSQL to MySQL syntax

**URL:** <https://forums.percona.com/t/new-to-mysql-convert-mssql-to-mysql-syntax/1020>\
**Category:** Other MySQL® Questions\
**Created:** [December 3, 2008, 9:58pm UTC](https://forums.percona.com/t/new-to-mysql-convert-mssql-to-mysql-syntax/1020 "2008-12-03T21:58:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdraska](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@cdraska](https://forums.percona.com/u/cdraska)\
**Post date:** [December 3, 2008, 9:58pm UTC](https://forums.percona.com/t/new-to-mysql-convert-mssql-to-mysql-syntax/1020/1 "2008-12-03T21:58:34Z")

</div>

So I am very new to MySQL but not MSSQL Server here is a simple sp that is a transaction with a try catch and system functions to return error information. I am looking for simple conversion to MySQL syntax. Can someone please translate so I can have a little template.

CREATE PROCEDURE [dbo].[spDELETE\_TREATMENT]  
@treatmentid as int  
@errorMessage as varchar(1000) output,  
@errorProcedure as varchar(1000) output,  
@errorLine as int output,  
@errorNumber as int output,  
@errorSeverity int output,  
@errorState as int output

– =============================================  
– Author:   
– Create date: \<August 1, 2007\>  
– Description:   
– Called from: \<NewTreatmentForm.aspx.vb\>  
– =============================================

as

BEGIN  
SET NOCOUNT ON;  
BEGIN TRAN

BEGIN TRY

–do some updates or deletes…

–raise an error to jump to catch block and set output variables  
RAISERROR(‘xxxxx’,16,1)

COMMIT TRAN  
SET @error = 0  
SET @errorMessage = NULL  
SET @errorProcedure = NULL  
SET @errorLine = NULL  
SEt @errorNumber = NULL  
SET @errorSeverity = NULL  
SET @errorState = NULL  
RETURN @error  
END TRY

BEGIN CATCH  
ROLLBACK TRAN  
SET @error = -100  
SET @errorMessage = ERROR\_MESSAGE() --MSSQL system function  
SET @errorProcedure = ERROR\_PROCEDURE()–MSSQL system function  
SET @errorLine = ERROR\_LINE() --MSSQL system function  
SEt @errorNumber = ERROR\_NUMBER() --MSSQL system function  
SET @errorSeverity = ERROR\_SEVERITY() --MSSQL system function  
SET @errorState = ERROR\_STATE() --MSSQL system function  
RETURN @error  
END CATCH  
END

---

<div class="post-metadata">

**Author:** ![xaprb](https://avatars.discourse-cdn.com/v4/letter/x/49beb7/32.png) [@xaprb](https://forums.percona.com/u/xaprb)\
**Post date:** [January 23, 2010, 12:13pm UTC](https://forums.percona.com/t/new-to-mysql-convert-mssql-to-mysql-syntax/1020/2 "2010-01-23T12:13:05Z")

</div>

MySQL’s syntax for stored procedure code is much simpler than MSSQL’s. There is much less ability to handle errors.
