Sometimes in MSSQL, you need to mimic the Oracle ROWNUM functionality. Here are some tips on ways to compress it into a single line of SQL. Continue reading “Oracle-like ROWNUM in MySQL”
Tag: MySQL
Convert Moodle Timestamp fields to Date
I get really frustrated with Moodle for using int fields to store dates. They store it in the Unix (Epoch) format. Here’s how to make it more readable.
To convert it to a readable date, use
FROM_UNIXTIME(int)
You can also get more formatting control with something like:
FROM_UNIXTIME(int, '%Y %D %M %h:%i:%s %x')
Search through text of Stored Procedure
Code to search across the text of all stored procedures for a particular string.
SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE ‘%foobar%’
AND ROUTINE_TYPE=’PROCEDURE’