Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Export option (right click in the database - tasks - export data...) Expand / Collapse
Author
Message
Posted Thursday, March 18, 2010 5:08 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Thursday, August 14, 2014 9:46 AM
Points: 743, Visits: 1,055
Hi,

In the past (SQL Server 2000) when i used the export option (right click in the database name, to export objects to other database) if i wanted to send a table from one database to other, i could send the primary key, create the identity fileds as the source table in the destination database.

I have searched for this option in SQL Server 2005, but it i think that it does not exist, as far as i can see, i can only send the table from the source database to the destination database , but i can not send the primary and the indexes and the Identity field to it, am i right?


Thank you
Post #885374
Posted Thursday, March 18, 2010 5:16 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:59 AM
Points: 11,194, Visits: 11,135
Do you want to take another shot at explaining that?

It is possible to do many things with the export data tool - I just need to understand the requirement a bit more. A simple example with a table schema and some example rows of data at both ends would probably help.




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #885380
Posted Thursday, March 18, 2010 5:25 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Thursday, August 14, 2014 9:46 AM
Points: 743, Visits: 1,055
lol, ok, i will try to explain better.

I have a table, this table as 4 columns. The first column (int) is an identity field and it's the primary key.

When i use the export data tool (to send the table to other database), i can send the table, but i cannot create in the destination database the primary key and the identity field.


Thanks,

Pedro
Post #885383
Posted Thursday, March 18, 2010 5:29 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:59 AM
Points: 11,194, Visits: 11,135
river1 (3/18/2010)
When i use the export data tool (to send the table to other database), i can send the table, but i cannot create in the destination database the primary key and the identity field.

Thank you Pedro. Just to be absolutely clear, you want to transfer the whole table, including the column with the IDENTITY property, and re-create the primary key. The IDENTITY column should retain the same values too...right?




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #885386
Posted Thursday, March 18, 2010 5:43 AM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Thursday, August 14, 2014 9:46 AM
Points: 743, Visits: 1,055
No, the identity does not need to retain the same values. I just need to recreate the whole table (primary key and identity)
Post #885397
Posted Thursday, March 18, 2010 5:53 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 10:59 AM
Points: 11,194, Visits: 11,135
river1 (3/18/2010)
No, the identity does not need to retain the same values. I just need to recreate the whole table (primary key and identity)

There is no way I can see to create the primary key - you would have to script that from SSMS.

To transfer the data, click the Edit Mappings button (on the table selection screen) and select the Enable Identity Insert option.

To transfer the structure without the data, choose the 'Write A Query' option and write something like SELECT * FROM dbo.Table1 WHERE 0 = 1;
Change the name from dbo.Query to dbo.Table1, and do the same trick as before with the Edit Mappings button / Enable Identity Insert.

Alternatively, if the table is small, script it from SSMS (Tasks...Generate Scripts), specifying the indexes to include, and also the Script Data option.

Paul




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #885404
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse