You can create your own formatting function for SQL.
Within the function you count the number of chars, in your case, to left of decimal. You can then determine if it's >= 1000 (where you would add begin to need the thousands separator) or just return the value.
If you have to work with it then you need to convert it to a string so you can insert your thousands separator.
Here's the hard part for you: figure out how you will insert multiple separators into your string when every time you add one the length of the string changes.
Now I made one of these myself, for MS SQL:
SET @RVAL = CONVERT(VARCHAR, CAST(@number as Money), 1)
which uses a built-in function to handle this for you. Notice that it's a CAST within a CONVERT and my cast is for USA style: (commas between thousands, period to mark the decimal break).