•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 402,915 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,103 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 650 | Replies: 4
![]() |
•
•
Join Date: Dec 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I'm trying to find information on how to import selected data from one SQL database to another using C# (or any language for that matter) or the cmd line. aka: I dont want to use the wizard.
I could export to a CSV file, then import... but that seems needslessly complicated and (run) time consuming. Any suggestions?
I could export to a CSV file, then import... but that seems needslessly complicated and (run) time consuming. Any suggestions?
•
•
Join Date: Jul 2008
Posts: 20
Reputation:
Rep Power: 1
Solved Threads: 3
Dear mayzebra ,
if you need to make copy (x) tables in database 1 to database 2 with same data.
you can better make a database replication.
check this link
http://technet.microsoft.com/en-us/l...chNet.10).aspx
but if you want to do this by code to make changes in data or specific data to be moved..
first solution : If the 2 database in same server
you can make stored procedure in SQL:
with command
like this:
If I don't understand your questions, explain more, and I will help you as I can
if you need to make copy (x) tables in database 1 to database 2 with same data.
you can better make a database replication.
check this link
http://technet.microsoft.com/en-us/l...chNet.10).aspx
but if you want to do this by code to make changes in data or specific data to be moved..
first solution : If the 2 database in same server
you can make stored procedure in SQL:
with command
like this:
insert into database1.dbo.table1 (col1,col2,col3) select col4,col5,col6 from database2.dbo.table2 where (where condation)
If I don't understand your questions, explain more, and I will help you as I can
Amir S.Bedair
Senior Solution Developer
Please rate my answer
Senior Solution Developer
Please rate my answer
Here is the command prompt commands to generate hte script of database tables and the data in these tables.
But to use these commands you have to download and install "DatabasePublishingWizard" this will create the "sqlpubwiz.exe" at your installation directory. This tool is not installed if you are using the sqlexpress 2005
Command to run which will create schema and database:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql”
Command to run which will create schema:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -schemaonly
Command to run which will create data:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -dataonly
But to use these commands you have to download and install "DatabasePublishingWizard" this will create the "sqlpubwiz.exe" at your installation directory. This tool is not installed if you are using the sqlexpress 2005
Command to run which will create schema and database:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql”
Command to run which will create schema:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -schemaonly
Command to run which will create data:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -dataonly
Thanks and Best of Lusk,
Farid ud din Masood
MS.c (CS)
University of Agriculture, Faisalabad
Farid ud din Masood
MS.c (CS)
University of Agriculture, Faisalabad
•
•
Join Date: Aug 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Dear mayzebra ,
if you need to make copy (x) tables in database 1 to database 2 with same data.
you can better make a database replication.
check this link
http://technet.microsoft.com/en-us/l...chNet.10).aspx
but if you want to do this by code to make changes in data or specific data to be moved..
first solution : If the 2 database in same server
you can make stored procedure in SQL:
with command
like this:
insert into database1.dbo.table1 (col1,col2,col3) select col4,col5,col6 from database2.dbo.table2 where (where condation)
If I don't understand your questions, explain more, and I will help you as I can
how to do the same, if the databases are in two different servers
•
•
Join Date: Jul 2008
Posts: 20
Reputation:
Rep Power: 1
Solved Threads: 3
Dear tharakaw
Please read MSDN help and check all the child pages from how to configure and make linked server :
http://msdn.microsoft.com/en-us/library/ms188279.aspx
regards,
Amir
Please read MSDN help and check all the child pages from how to configure and make linked server :
http://msdn.microsoft.com/en-us/library/ms188279.aspx
regards,
Amir
Amir S.Bedair
Senior Solution Developer
Please rate my answer
Senior Solution Developer
Please rate my answer
![]() |
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
age amd avatar backup blue gene breach business chips daniweb data data protection database developer development dos energy enterprise europe government hardware hp ibm ibm. news it linux management studio 2005 medicine memory microsoft news office open source openoffice pc ps3 red hat security server software sql sun supercomputer supercomputing survey technology trends ubuntu vista working x86
- How to import Excel Sheet data into SQL Server 2003 ???? Stpes. (MS SQL)
- MySql file (MySQL)
- Any way to combine two datasources into one recordset? (ASP)
- Importing SQL Script File - Urgent !! (Database Design)
Other Threads in the C# Forum
- Previous Thread: Selected Text
- Next Thread: How to navigate forms in Visual C#


Linear Mode