How to use IP address when calling a SQL Store Procedure

Posted on 2010-01-11
Medium Priority
Last Modified: 2012-05-08

I am writing a stored procedure which inturn calls many store proc from different servers.

I can use something like DatabaseServerName.Databasename.dbo.Databasetable and it works.

Now i want to use IP instead of databaseservername, something like it fails with an exception...

Line 7: Incorrect syntax near '100.10'.

I know i am not prefixing the IP in a proper way...can anybody suggest a proper way to use?

Question by:Star79
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 26285719
You need to create a linked server first, then only you can use the 4 part names , you can enclose the names of the sever, db within []

Author Comment

ID: 26285761
any other alternatives.
LVL 57

Expert Comment

ID: 26285842
create a mapping on the db

as ip, linkname and use this table to construct your sql, @sqlStatement, and use:

exec sp_executesql @sqlStatement
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 26285853
LVL 57

Accepted Solution

HainKurt earned 2000 total points
ID: 26285871
cant you use ip for linked name and use siomething like this

LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 26285955
>cant you use ip for linked name and use siomething like this

But he nee dto create the linked server first
LVL 75

Expert Comment

by:Anthony Perkins
ID: 26286542
See if OPENROWSET(), OPENDATASOURCE() and/or OPENQUERY() work for you?
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 26329195
does that work without creating the linked server

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question