October 31, 2012 at 2:30 am
I wanted to copy a table and its data to another db in another pc.... I was wondering wether there is a way to generate a query that holds all the data of original table so I could just execute it to the other 2nd table and have exact data.
thank you
October 31, 2012 at 2:44 am
A number of ways to do this.
Create a linked server on 1 of the machines then use a cross server query to pull out the data, something like
select * into destinationdb.dbo.tablename from linkedservername.sourcedb.dbo.tablename
Use the import export data wizard to copy the data from one place to another
Create a custom SSIS package which does what you need
Get a copy of SSMSTools Pack, and use the generate data scripts functionality to script out the data.
BCP Out and then BCP In
October 31, 2012 at 3:13 am
IF u don't wish to connect the two databases BCP in/out will be a good solution for you.Perform a BCP out operation on the source and get the data on a file.Then insert the data in the file onto a database using BCP in command.
October 31, 2012 at 3:40 am
Another option is to use SSIS or the Import wizard to pull the data over from the other server.
_________________________________________________________________________
SSC Guide to Posting and Best Practices
October 31, 2012 at 4:33 am
I could have done this... but my B server is a remote server, that don't accespt IMPORT db...
Create a linked server on 1 of the machines then use a cross server query to pull out the data, something like
select * into destinationdb.dbo.tablename from linkedservername.sourcedb.dbo.tablename
thankx will try the other options too
October 31, 2012 at 7:55 am
You don't need SSMSToolsPack to generate a script for the data. You can right click the database Taks -> Generate Scripts to bring up the Script wizard. On the Set Scripting Options section click the Advanced button. The last option in the first section of options (General) is "Types of data to script". By default this is set to Schema only. You can change that to Data only or Schema and data. If you choose the last one it will generate your create object script and inserts for all of the data.
--EDIT--
Of course SSMS Tools pack is a pretty darn handy extension though.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
November 5, 2012 at 12:49 am
Sean Lange (10/31/2012)
You don't need SSMSToolsPack to generate a script for the data. You can right click the database Taks -> Generate Scripts to bring up the Script wizard. On the Set Scripting Options section click the Advanced button. The last option in the first section of options (General) is "Types of data to script". By default this is set to Schema only. You can change that to Data only or Schema and data. If you choose the last one it will generate your create object script and inserts for all of the data.--EDIT--
Of course SSMS Tools pack is a pretty darn handy extension though.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply