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
 General SQL Server Forums
 New to SQL Server Programming
 get bcp to over write instead of append

Author  Topic 

Westerberg
Starting Member

18 Posts

Posted - 2006-04-05 : 12:06:07
I have a bcp command that works fine except that I want it to over write what is in the table rather than append to it. Is there a way to do this or another method I should try?

nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-05 : 12:37:57
Just run a delete or truncate before the bcp.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Westerberg
Starting Member

18 Posts

Posted - 2006-04-05 : 14:12:34
You can delete contents of a table through DOS commands?
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-04-05 : 15:11:33
Yes:
osql -SmyServer -E -dmyDatabase -Q"truncate table myTable"
Look up "osql" in Books Online if you need to change the syntax. Run that DOS command before you run your bcp command, like Nigel suggested.
Go to Top of Page

Westerberg
Starting Member

18 Posts

Posted - 2006-04-05 : 16:10:10
I'll take a look at it. Thanks.
Go to Top of Page

Westerberg
Starting Member

18 Posts

Posted - 2006-04-06 : 08:46:48
Works great! Thanks for the help.
Go to Top of Page
   

- Advertisement -