SQL Server - How to Import Remote data base to Local DB

Asked By Ajay Paritala on 03-Nov-11 02:29 AM
HI,

Please help me this.

How can i import remote data db to local db please if there is another way tell me..
Thanks in advance...
Reena Jain replied to Ajay Paritala on 03-Nov-11 02:33 AM
Hi,

Well, BACKUP is executed by SQL Server, so the backup file will be generated by SQL Server. Either direct the file to the desired location when you do the backup (UNC path) or do it locally and then grab the file (COPY, FTP etc).


try this and let me know
Suchit shah replied to Ajay Paritala on 03-Nov-11 02:35 AM
Aside from that, Visual Studio's Team Suite or Visual Studio for DBAs should be able to generate the script you need to execute on the remote database. There are a lot of other tools as well, like CompareSQL, AdpetSQL, that can do this for you. If you don't mind manually doing it, SQL Server Management Studio can create scripts to recreate most tables, views, indexes, etc, but you'll need to do them one by one, and in the correct order.
Suchit shah replied to Ajay Paritala on 03-Nov-11 02:35 AM

I had used bcp to insert records in the csv file from the database table which is on the server. once the csv file is created bcp puts the file on the path specified, provided the server and the local machine are on the network. the folder in which the file is to be saved on the local machine should be shared.

below is the Stored procedure i have used with northwind db:

CREATE Procedure aa

As

Begin

Declare @cmd varchar(300)

Declare @outfile varchar(300)

Declare @file varchar(300)

set @file = 'SMATMMYY'

set @outfile = ('\\192.168.241.217\Share\'+@file+'.csv')

Print @outfile

set @cmd = 'BCP "exec '+ db_name() +'..spsp " QUERYOUT ' + @outfile + ' -c -t "," '

Print @cmd

Exec master..xp_cmdshell @cmd

end

GO

CREATE Procedure spsp

As

Begin

select * from northwind..orders

end

GO

Anoop S replied to Ajay Paritala on 03-Nov-11 05:35 AM
If you would like to migrate the data in a SQL Server Database from development server to production server or vice versa , there is a tool called DTSWizard which comes with SQL Server installation that import and export data between a Data Source and Destination Source.

refer this for more details : Export/Import Data From Local Database To Remote Database With MS SQL Server 2008
http://4rapiddev.com/sql-server/exportimport-data-from-local-database-to-remote-database-with-ms-sql-server-2008/