title: Function to return ip address based on computer name T-SQL
body: <p>I have a table in sql server containing a list of computers in the domain. It has a column called <code>FQDN</code> which contains the names of the computers. I added a column for the IP as a <code>nvarchar</code> (I will format it later). Instead of filling the ip manually I wonder if I can create a function to get them from the dns based on the names in the name column. For example in powershell if I type this <code>[System.Net.Dns]::GetHostAddresses("yourhosthere").ipaddresstostring</code> and store it in a variable I get exactly what I want. I was not able to embedd the above powershell in a function in sql server and then iterate over the name column to update the ip column. I tried of course <code>EXEC xp_cmdshell</code> with <code>powerhell.exe</code> but to no avail.</p>