Sample SQL script in CRM to update tables in CRM DB

Hi All,

I am new to coding for Sage CRM and trying to learn the correct syntax/methodologies we can use while coding for SQL Stored Procedures/Scripts to perform DML Statements in Sage CRM. 

In case anyone has the experience, can you please share a sample script for reference. I am trying to put some conditional cases and wanted to learn the syntax for exception handling in the code. Recommendations/advise please share some samples. 

Thanks

AJ