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 2005 Forums
 SSIS and Import/Export (2005)
 Transfer SQL Server Objects Task

Author  Topic 

scabral7
Yak Posting Veteran

57 Posts

Posted - 2010-05-22 : 21:00:51
does anyone know if it is possible to use a list of tables to use in the Transfer SQL Server Objects Task step in SSIS for the Object List parameter?

I want to move about 500 tables from SQL 2000 to Sql 2005 using SSIS but i don't want to have to check each table off, rather i have the table names stored in a table and would like to query that and have that list be the used for the Object List for my tables.

Any ideas if this is possible?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-22 : 23:28:37
Do you have to use SSIS? How many tables are there in the 2000 database? Can you instead do backup/restore and delete the objects you don't want after the restore? Or does the 2005 database already exist with objects you want to keep? Is bcp.exe an option as we can easily script out the command using dynamic SQL and INFORMATION_SCHEMA.TABLES view?

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

Subscribe to my blog
Go to Top of Page

scabral7
Yak Posting Veteran

57 Posts

Posted - 2010-05-22 : 23:38:26
Hi Tara,

the 2005 database does already exist, but i have about 500 tables that need to be 'refreshed' with data from the 2000 database. I'm curious about the bcp process. Do you have an example of how to write the script to pass data from each table to the 2005 db?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-22 : 23:44:43
This will get you started and is from memory:

Run this on the 2000 system to generate the output:
SELECT 'bcp dbNameGoesHere.dbo.' + TABLE_NAME + ' out c:\temp\' + TABLE_NAME + '.csv -t, -Sserver1\instance1 -T -c -r\r\n'
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME ... <-- this is where you'll need to do some work

The above should produce all of the commands that you'll need to export the data to flat files in comma delimited format.

Now copy/paste that into a batch file (.cmd or .bat) and run it.

Next generate the import commands by running the above query on the 2000 system with a slight difference:
SELECT 'bcp dbNameGoesHere.dbo.' + TABLE_NAME + ' in c:\temp\' + TABLE_NAME + '.csv -t, -Sserver2\instance1 -T -c -r\r\n'
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME ... <-- this is where you'll need to do some work

Make sure that the first SELECT points at your 2000 system for the -S switch and that the second one points at your 2005 system.

Now copy the above output into another batch file and run it. This should import all of the data from the files into your 2005 system.

I probably have the commands a little off, but it should give you a good start. The key is to make sure that the output of each SELECT is correct before putting them into a batch file.

On Monday, I'll be at work and in front of a SQL Server system, so I can better help you out if you run into any problems. Let me know your progress on this. I will probably check SQLTeam tomorrow too, but any help I provide will be just my best guess as I don't plan on connecting to a SQL Server system this weekend!

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

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-22 : 23:48:57
I didn't notice until now that you have the table names stored in a table already. So replace INFORMATION_SCHEMA.TABLES in my queries with your table and the TABLE_NAME column too.

The point of my queries is to generate the bcp commands.

By the bcp is an executable (bcp.exe) that allows you to import/export data in SQL Server. It isn't as powerful as SSIS, but it doesn't sound like you need to transform any data here, so bcp.exe should work just fine.

You'll have bcp on your system if you have the SQL client tools installed. If it's not in your computer's path variable, then you can fully qualify it in the above queries. It'll be located in the BINN directory somewhere underneath Microsoft SQL Server folder. I'd look it up for you, but I don't have SQL Server on the system I'm using right now.

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

Subscribe to my blog
Go to Top of Page

scabral7
Yak Posting Veteran

57 Posts

Posted - 2010-05-23 : 01:17:33
Thanks Tara,

i guess i'm just worried about how big these files will be and if i have enough room to store them on the server. I may have to to them 20 or 30 at a time, but i'm not sure. I don't really know how much data each table has, but i'm sure some of them are rather large.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2010-05-23 : 12:12:05
What about Constraints?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-23 : 12:17:17
Good point sodeep. In my solution, I'd drop the constraints before the import and then add them back after the import.

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

Subscribe to my blog
Go to Top of Page
   

- Advertisement -