Implementing Luhn Algorithm to different platforms.
More infomation can be found in Wikipedia
You can checkout the code for SQL implementation here.
This can be set as a SQL function if you wanted to do a quick check, however, you can just use a stored procedure for the code to be implemented.