Any syntax where i will copy an sql server table to another table using BCP.im using sql server 2000 on vb.net, DTS isn't working for me because i want to edit some conditions on the package and it just dont work well.thanks in advance!are the 2 tables in the same database, or the same server or on the same network? you may be able to do this with a simple
INSERT INTO MyTable(MyField)
SELECT
using fully qualified names and maybe a linked server.|||if you want to use bcp, you have to do it in 2 steps:
1. use bcp with "out" or "queryout" keywords to go from source table to flat file
2. use bcp with "in" keyword to go from flat file to dest table.
if you have many millions of rows, bcp is faster than using INSERT...SELECT.
read about bcp syntax here:
http://msdn2.microsoft.com/en-us/library/ms162802.aspx
Another option, since you are using .net, is to use the sqlbulkcopy class, which has the advantage of not needing to write the intermediate file. It's quite fast. Read up here: http://msdn2.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.aspx. I recommend you to use the overload of WriteToServer that takes IDataReader, not the DataTable overloads. much more memory efficient.|||Thanks..maybe i forgot that one..workin on it now..hope it will be much faster|||thats what im thinking..i have to do two steps..good if im transferring it to other database or web.will it still be much faster than 'Insert...Select' statement in two steps?...|||it depends on how many rows you are moving. if it's millions, bcp/bulk insert/sqlbulkcopy will be faster than INSERT...SELECT.
If you have lots of rows, I would try sqlbulkcopy. it's only one step, and uses the same underlying method as bcp, namely, bulk insert.
没有评论:
发表评论