Implement toSql method