Author Archives: admin

SQL TRIM

The SQL TRIM() function is used to remove the leading or trailing spaces of a string. Different databases have different writtings:

SQL Server LTRIM(), RTRIM()
Oracle LTRIM(), RTRIM()
MySQL TRIM(), LTRIM(), RTRIM()

In SQL Server or Oracle it doesn’t have Trim() function, we can combine LTrim() and RTrim():

RTRIM(LTRIM(str))

Continue reading

SQL NOW

The SQL NOW() function will return current date and time based on server system.

It is supported by MySQL, in MS SQL Server, the function getdate() will do the same thing, and in Oracle we can use SELECT SYSDATE FROM DUAL to get the current date and time.

Continue reading