Named Pipe Provider Error code 40 I have literally tried everything, from enabling named pipe to adding exception to ports in the firewall, to everything possible in surface configuration. I can connect to the SQL instance(using TCP and Named Pipes) with SQL Server Management Studio. But sqlcmd throws an error:

Login timeout expired


Help!
You didn't give us a lot of detail, but this article covers most of the basics: http://msdn.microsoft.com/en-us/library/ms190181(v=sql.105).aspx