SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


can I get the cuerry of an existing table...???


can I get the cuerry of an existing table...???

Author
Message
Ahmed_07
Ahmed_07
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 16
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
anthony.green
anthony.green
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63266 Visits: 8598
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



How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


mwagh
mwagh
SSC Veteran
SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)SSC Veteran (203 reputation)

Group: General Forum Members
Points: 203 Visits: 31
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.
Jason-299789
Jason-299789
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12429 Visits: 3232
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
Ahmed_07
Ahmed_07
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 16
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
Sean Lange
Sean Lange
SSC Guru
SSC Guru (149K reputation)SSC Guru (149K reputation)SSC Guru (149K reputation)SSC Guru (149K reputation)SSC Guru (149K reputation)SSC Guru (149K reputation)SSC Guru (149K reputation)SSC Guru (149K reputation)

Group: General Forum Members
Points: 149699 Visits: 18575
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.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Ahmed_07
Ahmed_07
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 16

ExclamationIndeed I don't need SSMSToolsPack


;-)this was a tremendous help thank you so much and works JUST FINE :-)




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.

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search