Link to home
Start Free TrialLog in
Avatar of Zaurb
Zaurb

asked on

How to automatically delete data from table in SQL Server before BCP is launched.

Hi!

I'm using bcp.exe to insert data into SQL Server 2005 Express Edition. How do I get rid of the existing data in SQL Server table each time I run bcp.exe to insert new data.

The process must be automated. For this reason I can't run manually TRUNCATE TABLE table_name each time before the bcp is launched.

Thank you!
ASKER CERTIFIED SOLUTION
Avatar of chaturam
chaturam

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zaurb
Zaurb

ASKER

Hi Chaturam,

The problem is that I'm using an SQL Server 2005 Express Edition. I can't find SQL Server Agent under the Object Explorer in Management Studio.

Is there another way to configure that?

Thank you!
Avatar of Zaurb

ASKER

OK, I think I resolved this issue by scheduling sqlcmd utility. It works, but...
any better solutions will be greatly appreciated. I'm sure there are much better and more effective approaches.

Thank you!
SOLUTION
Avatar of Racim BOUDJAKDJI
Racim BOUDJAKDJI
Flag of Algeria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zaurb

ASKER

Thanks!
But again, since I use EXPRESS Edition there's no SQL Server Agent for using Job Step...
Is there any external tool or some other method for that?

Thank you!
You may run the TSQL statement I gave you before running the bcp statement and by calling the osql command line...That way the statement for checking the existence of a specific table would be ran each time the bcp is ran...

Hope this helps
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial