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)
 Sql query

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2011-10-27 : 21:04:30
I want to insert 1.5 billions records every day from one database table to another database parition table on same server.

What is the efficient query to perform the above operation with better performance.


BEGIN
INSERT destinationDB.dbo.StudentList (StFName,StLName,StEmail,OrderID)
select StFName,StLName,StEmail,OrderID from SourceDB.dbo.studentlist
end

Thanks for your help in advance !

X002548
Not Just a Number

15586 Posts

Posted - 2011-10-27 : 22:40:12
bcp out native..bcp in

BUT why the hell would you want to do that?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2011-10-27 : 22:44:28
Thanks


I have the requirement to do that.


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-28 : 05:17:24
quote:
Originally posted by sqlfresher2k7

Thanks


I have the requirement to do that.





few things to note

1.make sure you schedule this data population out of normal office hours
2. hope your destination table doesn't have too much indexes, if yes it might be worth dropping them before population and recreate it afterwards
3. remember to update statistics after data dumping process


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2011-10-28 : 08:25:14
Thanks visakh

It has one indexes on a table I will drop the index before loading.
Do I have to use bcp or the above insert script.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-28 : 08:40:58
bcp will be bulk operation so will be faster than insert

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2011-10-28 : 21:44:34
Thanks visakh

It has one indexes on a table I will drop the index before loading.
Do I have to use bcp or the above insert script.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-29 : 01:00:50
quote:
Originally posted by sqlfresher2k7

Thanks visakh

It has one indexes on a table I will drop the index before loading.
Do I have to use bcp or the above insert script.


i thought i answered you in last post

just to reiterate

bcp will be bulk operation so will be faster than insert

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2011-10-29 : 12:53:26
Here's a easily modified script that should help you out.

http://blogs.msdn.com/b/patrickgallucci/archive/2007/08/10/generate-bcp-bulk-insert-code-with-tsql.aspx


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page
   

- Advertisement -