The latter might be accomplished by some program/script that can communicate with both the SQL server and the router.
As @Georg Pauwen also inquires, there's related question of how you would inject and/or store and/or also use these SQL prefixes on the router. For example, you might format the SQL prefixes as static routes and/or ACL ACEs, or a program that communicates with both the SQL server and router, might "talk" to the router via a dynamic routing protocol.
As already said there will not be a direct connection between a router and an SQL database.
If you have any experience scripting/programming you may want to look at Python which has a Netmiko module which makes it easy to connect to Cisco devices and execute commands and also has modules for connecting to SQL databases.