Soldato
- Joined
- 17 Nov 2005
- Posts
- 3,108
- Location
- Swindon, UK
Hello,
SQL 2000 on Windows Server 2003
I was wondering if you all could help.
I have a DOS Batch file that imports data into a SQL 2000 DB using BCP. I want to clear out the exisitng data first and trucate the table using OSQL.
Obviously if it all went wrong, how would I rollback so that the original tables weren't truncated using the batch file?
Can the OSQL and BCP commands work together in a SQL transaction within a DOS Batch file?
SQL 2000 on Windows Server 2003
I was wondering if you all could help.
I have a DOS Batch file that imports data into a SQL 2000 DB using BCP. I want to clear out the exisitng data first and trucate the table using OSQL.
Code:
osql -dMy_Data -E -Smyserver -Q "BEGIN TRANSACTION MyTransaction TRUNCATE TABLE film COMMIT TRANSACTION MyTransaction"
bcp My_Data.dbo.film in film.txt -q -n -t -T -Smyserver
Obviously if it all went wrong, how would I rollback so that the original tables weren't truncated using the batch file?
Can the OSQL and BCP commands work together in a SQL transaction within a DOS Batch file?