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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 bcp fails to overwrite

Author  Topic 

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2010-09-08 : 15:59:19
hi friend i have a bcp command in
a stored procedure that extracts a view to a csv format. If the file is already there it simply overwrites it but when the file is being used it does not do that but the sql job that uses the stored procedure show as executed successfully . Is there a way to catch this?

thanks in advance.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-08 : 16:11:05
I don't think there is a way to do it in T-SQL, but googling it, it seems you can do it with VBScript. Here's one such example: http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23190324.html

Have the job check if the file is open first, and then run the stored procedure only if the file is closed. You can use RAISERROR if the file is open so that the job fails.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2010-09-08 : 16:26:36
thank you tkizier but i cannot view the solution due to subscription issue...can you post it here....thanks once again
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-08 : 16:31:46
You don't need to subscribe, just scroll all the way down.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

akpaga
Constraint Violating Yak Guru

331 Posts

Posted - 2010-09-08 : 16:38:27
it not showing anything but asking me subscribe tkizer...
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-08 : 16:56:19
Ok then how about googling it: http://www.google.com/search?rlz=1C1GPMD_enUS313US313&aq=f&sourceid=chrome&ie=UTF-8&q=vbscript+how+to+check+if+file+is+open

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-09-08 : 17:09:16
Why not use SSIS?



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -