0

How can I use an ipaddress instead of server name in a Sql Query for example.

SELECT * FROM [ipaddress].[databaseName].[dbo].[TableName] 

Instead of [serverName].[databaseName].[dbo].[TableName] I wanted to get the info from a system of xx.xx.xxx.xx IP address.

Instead of serverName I want to get the data from this PC with MSSQL-server installed.

jarlh
  • 42,561
  • 8
  • 45
  • 63
user9630935
  • 349
  • 1
  • 4
  • 18
  • Maybe you use a connection string? Then you don't need to add this into your Querry Maybe add a Port to the IP Adress – LoaStaub Jun 13 '19 at 08:06
  • 2
    You would need to register the linked server with it's name being the IP address instead. – Thom A Jun 13 '19 at 08:07
  • 1
    `sp_setnetname` allows you to use IP addresses for the "real" server name. If the IP address can vary per query, use `OPENROWSET` instead (you'll need to configure the server to allow ad-hoc queries for this). – Jeroen Mostert Jun 13 '19 at 08:29

1 Answers1

0

Register the server as a linked server and use the IP address as the linked server's server name.

Dale K
  • 25,246
  • 15
  • 42
  • 71
Michael Tobisch
  • 1,034
  • 6
  • 15