Need to check file existence in T-SQL scripts.
DBA suggested not using xp_fileExist , example as below :
declare @FileOK INT
exec xp_fileExist 'D:\TmsCallUpdate\TmsCallUpdate.csv',@FileOK OUTPUT
Print @FileOK
if @FileOK=1
BEGIN
....
END
Then turn to CLR, to use CLR create a function and delpoy to Database Server :
Use VS 2010, create a SQL server 2005 project , add a function ,then build and deploy to DB server. The function or procedure will be under "Store Procedures" or "Functions" as normal ones.
Reference :
http://carlosbercero.com/post/?post=How_to_create_an_SQL_CLR_Project_in_Visual_Studio_2008
http://carlosbercero.com/post/?post=Writing_a_CLR_Stored_Procedure_on_SQL_Server
本文探讨了在T-SQL脚本中检查文件是否存在的一种替代方法:避免使用xp_fileexist,并介绍了通过CLR创建自定义函数部署到数据库服务器的具体步骤。

1446

被折叠的 条评论
为什么被折叠?



