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.
| Author |
Topic |
|
smcgrath12
Starting Member
3 Posts |
Posted - 2004-04-06 : 09:40:36
|
| SET XACT_ABORT ONBEGIN TRANDeclare @mysql nvarchar(3000)Set @mysql = "insert into..."Exec sp_executesql @mysqlIF (@@ERROR <> 0)BEGIN GOTO tran_failure_blockENDSet @mysql = "delete from..."Exec sp_executesql @mysqlIF (@@ERROR <> 0)BEGIN GOTO tran_failure_blockENDSet @sql = 'Exec master..xp_cmdshell (Runs a BCP In/Out here)'Exec (@sql)IF (@@ERROR <> 0)BEGIN GOTO tran_failure_blockENDCOMMIT TRANRETURNtran_failure_block:BEGIN ROLLBACK TRAN RETURNENDGOThis is the meat of my stored procedure. Anyways, the problem is withthe last command (xp_cmdshell) which I use to run BCP in and out operations.Now, the problem is, if there is any error in the BCP, I can't catch it in the stored proc, as I would imagine, BCP runs out of process from sql server.I really want everything to go, or nothing to go and if there any errors in myxp_cmdshell bcp, I want to catch it and rollback the entire transaction.Any ideas??? |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-04-06 : 15:24:35
|
| Use INSERT INTO #table(values) EXEC xp_cmdshell.Look at the results and continue.?MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
GunterKDR
Starting Member
5 Posts |
Posted - 2004-04-06 : 15:43:36
|
| You could also use the BULK INSERT tsql command,this doesn't address your bcp out concerns, but it gets you half way there.Good Morning-GunterThey that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety. -- Benjamin Franklin |
 |
|
|
smcgrath12
Starting Member
3 Posts |
Posted - 2004-04-08 : 15:28:55
|
| Thanks guys. Appreciate your ideas. |
 |
|
|
|
|
|