There's a bunch of examples out there. You need to first pick a connection method. If you have the SQL native client installed, that's a good way to go. I don't know SQL Server as well as I'd like, so I can't say what is the "best", but there are several others. They all have one thing in common and that's the concept of a connection string. You can find out how to make for your case here:
http://www.connectionstrings.com/ Also check out BSonPosh's
Google custom search engine, search for sql there.
Here's an example using System.Data.SqlClient.SqlConnection (that I ripped off from
channel 9 wiki).
function sqlConnect ([string]$connString)
{
$sqlConn = new-object System.Data.SqlClient.SqlConnection;
$sqlConn.ConnectionString = $connString;
$sqlConn.Open();
$sqlConn.Close();
}