Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Import/Export From database to another Automated?

Author  Topic 

sentinelace
Starting Member

34 Posts

Posted - 2011-12-13 : 14:31:05
I have two databases. I want to schedule a dump from one database but only copy over a few tables each day without having to do it manually. I thought you could do this in 2005 with import/export. What is the best way of doing this?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-13 : 14:32:40
Yes you can do this through import/export wizard by scheduling it. It asks at the very end for what you want to do, i.e. run it now, schedule it as a package, etc.

Or you can create your package via SSIS and then schedule that.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sentinelace
Starting Member

34 Posts

Posted - 2011-12-13 : 15:03:57
I ran it but never got to that point. I create the SSIS package but then at the end it just says, hit finish to perform these actions. What did I miss?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-13 : 15:10:43
If it created the SSIS package, then you can now schedule that package to run by adding a SQL Agent job.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sentinelace
Starting Member

34 Posts

Posted - 2011-12-13 : 15:12:12
Great! When I try and create the job and run it manually it says sa login failed? Why? I can connect to the DB fine with SA. The log shows:

Login failed for user 'sa'. Reason: Password did not match that for the login provided. [CLIENT: <local machine>]
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-13 : 16:35:35
It seems the package has a bad password in it. Edit the package to fix that and then try manually running it.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sentinelace
Starting Member

34 Posts

Posted - 2011-12-13 : 16:41:12
I am not 100% I am looking at the right log either. How do you edit the package once it's been created?


Started over with same error. I am logged on to the server as "administrator" and connected to the database as "SA" and tried "Administrator" with same result.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-13 : 16:53:51
Make sure you save the package to the file system.

It's not how you are logged in that is the problem, it's the settings inside the package.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sentinelace
Starting Member

34 Posts

Posted - 2011-12-13 : 17:04:12
I saved it to the file system and I get a failed on step 2 every time. I have recreated the package now 5 times with the same result. I have the same username and password on both databases. Where is the log? I'm not seeing much to help troubleshoot the error? That is the error located under sql logs.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-13 : 17:19:14
Can you instead use Windows authentication?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sentinelace
Starting Member

34 Posts

Posted - 2011-12-14 : 07:22:28
I have enabled logging with visual stuido and I see this error when running the job:

An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Violation of PRIMARY KEY constraint 'TEST_GRP_PK'. Cannot insert duplicate key in object 'dbo.TEST_GRP'.".
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-14 : 11:48:17
You will probably need to add a step in your package to DELETE or TRUNCATE the table before it copies the data.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sentinelace
Starting Member

34 Posts

Posted - 2011-12-14 : 13:02:44
Perhaps. This is one step process now. How do you split it up to delete first, then copy?

When I try to delete from studio I get referenced by a foreign key constraint. And it won't delete there.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-14 : 13:25:49
If you've got foreign key constraints and you are refreshing parent tables, then this just got a bit more complex. You are going to need to refresh all tables involved in the foreign keys. You'll start by deleting from all of them and then doing the insert. As for how to do this, well you'll need to edit the SSIS package to add a SQL step in there with your delete code.

I'd highly recommend abandoning the SSIS package at this point and instead just using T-SQL. Can you get away with a backup/restore instead?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sentinelace
Starting Member

34 Posts

Posted - 2011-12-14 : 13:29:55
I don't care what process honestly as long as I can restore paticular tables to this second database. The SSIS package seemed to be the easiest method but obviously not. How do we proceed now?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-14 : 13:34:02
If you can't use backup/restore (would give you a total refresh and not just particular tables), then you'll need to track down all of your foreign key constraints for the particular tables. Then you'll need to spend some time ordering them. For the deletes that you'll need, the order would be child tables first and then parent tables. For the inserts, the order would be parent tables first and then child tables.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sentinelace
Starting Member

34 Posts

Posted - 2011-12-14 : 13:45:16
So I can just restore paticular tables from a backup?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-14 : 14:21:07
No as you'd be in this same predicament. My point about backup/restore is only if you can get away with refreshing the entire database. If you can't do that, then you'll need to figure out the FK's.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sentinelace
Starting Member

34 Posts

Posted - 2011-12-14 : 14:41:48
Okay. If found a script that gives me the PK's and FK between all the tables and the relation, but I only see one of the tables I need. Maybe the other ones don't have FKs? Now what is needed to move from here?
Go to Top of Page

sentinelace
Starting Member

34 Posts

Posted - 2011-12-15 : 10:58:05
bump. ;)
Go to Top of Page

sentinelace
Starting Member

34 Posts

Posted - 2011-12-19 : 08:28:25
I am contacting the company for that makes this software to see what they say about the keys. unlessy ou have another idea?
Go to Top of Page
    Next Page

- Advertisement -