If want to do this on the web using Flex you should use a web service written in some sort of server side language. Because you mentioned SQL Server, .NET is probably the way you want to go. You can write a WCF or ASP.NET web service to pull the data form the DB and then have Flex consume that web service.
One nice thing about web services is that generally they can be consumed by anything. So you could write the service and consume it in Flex, Silverlight, Windows Forms, WPF etc...
If .NET is the way you want to go simply Google .NET Web Services for samples.