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
 Transact-SQL (2008)
 Insert using select statement

Author  Topic 

nickfinity
Yak Posting Veteran

55 Posts

Posted - 2010-08-05 : 16:27:22
I need to pull some data in from another database. I've setup a linked server and am running some "insert into....select...." statements. It works, but is very slow. There are a lot (many millions) of records coming over. How inefficient is it to do it this way? It was a little faster when I used SSIS, but not much.

Back before some crashes, uninstalls, reinstalls, etc there was a DTS package that did this in about 2 hours. Now it's taking 7. I'm not sure the DTS package was ever backed up (or if it was where it exist). I used to be able to select a table to import and it would work, but now I have to specify a query because I get data type conversion errors when trying to do the table.

Thanks for any help, I really appreciate it.

Nick

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-05 : 16:32:18
You should be able to move millions of rows in just a couple of minutes. If you bulk load through SSIS, then it should be fast. You could also use bcp.exe to export to a file and then import via the file. I use bcp.exe for things like this, but a lot of people prefer GUI tools so that's why I mentioned SSIS.



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

Subscribe to my blog
Go to Top of Page

nickfinity
Yak Posting Veteran

55 Posts

Posted - 2010-08-05 : 17:01:35
Thanks for the help. After a quick look I think I'll try bcp. I think part of the problem is the database I'm pulling data from. It's really old and slow (not SQL Server). I'll have to setup a script to create the data files, but if I can avoid casting data types in that db I think it will speed things up.

Thanks again.

Nick
Go to Top of Page
   

- Advertisement -