Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8587813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:39:36+00:00 2026-06-11T22:39:36+00:00

I’m working with two databases. From 1st database in the server I’m taking all

  • 0

I’m working with two databases. From 1st database in the server I’m taking all the tables and inserting in local machine in one empty database using a stored procedure.

This is my stored procedure:

SET ANSI_NULLS ON
 GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[ImportScriptAndData]

@Branch int,
@MainServer varchar(20),
@LocalServer varchar(20),
@LocalDBName varchar(20),
@AuditType int

AS Begin

set nocount on;


-- Delete the master tables

-- dbo.AuditArea
print ('delete from ['+ @LocalServer +'].['+ @LocalDBName +'].[dbo].AuditArea')
exec  ('delete from ['+ @LocalServer +'].['+ @LocalDBName +'].[dbo].AuditArea')

-- Insert data into master tables

-- dbo.AuditArea
print ('insert into ['+ @LocalServer +'].[HDFCAudit].dbo.AuditArea
select * from ['+ @MainServer +'].[HDFCAudit].dbo.AuditArea')
exec ('insert into ['+ @LocalServer +'].['+ @LocalDBName +'].dbo.AuditArea
select * from ['+ @MainServer +'].['+ @LocalDBName +'].dbo.AuditArea')

End

This stored procedure is on server database.

I’m connecting two computers on lan. One is server and other is client

On client application I have a button that can be clicked when I want to bring all the tables from server database to local empty database.

My click button code is:

SqlConnection con = new SqlConnection(newConn);  //string newConn = "Data Source=Servername;Initial Catalog=Audit;uid=sa;pwd=admin@123";
            con.Open();
            SqlConnection conn = new SqlConnection(connectionstringLOCAL); //string connectionstringLOCAL = "Data Source=Clientname;Initial Catalog=Audit;uid=sa;pwd=admin@123";
            conn.Open();
            BranchCode = Convert.ToInt32(cboBranch.SelectedValue.ToString());
            MainServer = "Servername";
            LocalServer = "ClientName"; //express
            LocalDatabase = "Audit";
            AuditType = 1;
            SqlCommand cmd = new SqlCommand("dbo.ImportScriptAndData", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@Branch", SqlDbType.Int)).Value = BranchCode;
            cmd.Parameters.Add(new SqlParameter("@MainServer", SqlDbType.VarChar)).Value = MainServer;
            cmd.Parameters.Add(new SqlParameter("@LocalServer", SqlDbType.VarChar)).Value = LocalServer;
            cmd.Parameters.Add(new SqlParameter("@LocalDBName", SqlDbType.VarChar)).Value = LocalDatabase;
            cmd.Parameters.Add(new SqlParameter("@AuditType", SqlDbType.Int)).Value = AuditType;
            //cmd.Parameters.AddWithValue("@Branch", BranchCode);
            //cmd.Parameters.AddWithValue("@MainServer", MainServer);
            //cmd.Parameters.AddWithValue("@LocalServer", LocalServer);
            //cmd.Parameters.AddWithValue("@LocalDBName", LocalDatabase);
            cmd.ExecuteNonQuery(); // **error on this line**

And I’m getting following error on this line:

Could not find server ‘clientname’ in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.

What to do now?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:39:37+00:00Added an answer on June 11, 2026 at 10:39 pm

    To run distributed queries between two servers. seen must link the two servers.

    USE master;
    GO
    EXEC sp_addlinkedserver 
       N'Other Server',
       N'SQL Server';
    GO
    

    Link : http://msdn.microsoft.com/fr-fr/library/ms190479.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.