开发者

SQL : how to select the table from one server and how to insert into another server [duplicate]

开发者 https://www.devze.com 2023-04-05 07:02 出处:网络
This question already has answers here: After select the table from one server and how to insert into another server?
This question already has answers here: After select the table from one server and how to insert into another server? (2 answers) Closed 6 years ago.

I have two servers and I need to transfer all the details of a particular user from one server to another server

I selected row from one server and no开发者_JAVA百科w I have to insert into another server of a table

I selected the row and I return it in datatable

 select * 
 from [mp_Sites] 
 where SiteID = " + siteid + "

Now I called the stored procedure which is present in the server2 to insert into the table which is selected from server1

 cmd.CommandType = CommandType.StoredProcedure;

 cmd.Parameters.Add("@1", SqlDbType.Int).Value = moduleId;
 cmd.Parameters.Add("@2", SqlDbType.VarChar).Value = dtEventsXmls.Rows[i]["SettingName"].ToString();
 cmd.Parameters.Add("@3", SqlDbType.VarChar).Value = dtEventsXmls.Rows[i]["SettingValue"].ToString();
 cmd.Parameters.Add("@4", SqlDbType.VarChar).Value = dtEventsXmls.Rows[i]["ControlType"].ToString();
cmd.Parameters.Add("@5", SqlDbType.NText).Value = dtEventsXmls.Rows[i] ["RegexValidationExpression"].ToString();

I think its complicated - if you have any idea please let me know ..


  1. You can learn how to set up a "Linked Server" and easily do what you want to do. -or-
  2. You can use SSIS to do this. -or-
  3. You can use the BCP command line utility in SQL Server to export the data to a file and use the BULK INSERT t-sql command to insert it on the other server. This would be the fastest and simplest way to go. -or-
  4. You can use the Openquery command to access the other server in SQL code to get the data.
0

精彩评论

暂无评论...
验证码 换一张
取 消