Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

mssql how to select from table and insert into another server ?

Posted on 2013-01-12
3
Medium Priority
?
449 Views
Last Modified: 2013-01-22
i have two database what i need is to do something like this using sql server managment studio

the database  [mixmixmix]. is founded in the server 10.1.1.26
and the database [CGI_SMS_SERVICES] is founded in the server 10.1.1.5
the two sql server has login and password ?????????
how i can do this ?

/****** Script for SelectTopNRows command from SSMS  ******/

INSERT INTO [mixmixmix].[dbo].[CGI_SMS_dafif]
           ([reqport]
           ,[message]
           ,[msisdn]
           ,[datetimein])

SELECT 
      [ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[datetimein]
  FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d752265] 
  WHERE Datein between '20130109' and '20130111'

  union all 

  SELECT [ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[datetimein]
  FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d84486] 
  WHERE Datein between '20130109' and '20130111'

  union all 

  SELECT [ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[datetimein]
  FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d670131] 
  WHERE Datein between '20130109' and '20130111'

Open in new window

0
Comment
Question by:afifosh
3 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 1500 total points
ID: 38770120
0
 

Expert Comment

by:Ibrahim_Malhas
ID: 38770210
You can link these servers
http://msdn.microsoft.com/en-us/library/ff772782.aspx
or you can go to the first DB>>R.C>>Import Data
Choose the destination and the source to migrate the data
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 38781703
create link server and

do like

Insert Into Db.schema.table values(fld1, fld2) select fld1, fld2 from Linkedserver.database.schema.table
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

782 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