SQL Training Q&A - 5
Q) In connectionstrings I often see server=localhost. Where is this "localhost" name coming from? Is it in a file somewhere? Is it true that the server must be using TCP/IP for this to work? I also see server=. and server=(local) in connection strings. Do they work the same way and is there a different protocol being used or another setting?
Localhost is a name defined on every computer running TCP/IP and it maps to 127.0.0.1.
This is actually stored in the C:WINDOWSSYSTEM32DRIVERSETCHOSTS file. You do have to be using TCP/IP for localhost to be available.
You can get details at: https://www.microsoft.com/technet/itsolutions/network/evaluate/technol/tcpipfund/tcpipfund_ch07.mspx
"." and "(local)" are not in TCP/IP. Those are implemented in the connection string parser of the SQL Server client. Starting in ADO.NET 2.0, you can also specify the protocol using "tcp:(local)", "np:(local)" or "lpc:(local)".
You can get details at: https://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx