Suppose I have an Excel file in D:\Test with the name a.xls.
Can I rename that excel file from QA of SQL SERVER in the same location or any other location?
SubhasishYou can perform any dos commands via SQL using xp_cmdshell. You must ensure the SQL server has permissions to the location where the file resides if that location is not on the SQL server.
From QA type:
xp_cmdshell 'rename D:\Test.xls Test2.xls'
That should do the trick.
-Lee
MS SQL 2000 dba
Verizon Wireless|||you might even have an activex task to do this in your DTS package. Here is the code
======================================
Function Main()
Dim fs, MyFile
Dim FileLocation
Dim FileName
Dim FileInfo
FileLocation = "D:\Test\"
FileName = "a.xls"
FileInfo = FileLocation & FileName
Set fs = CreateObject("Scripting.FileSystemObject")
If (fs.FileExists(FileInfo)) Then
fs.MoveFile (FileInfo),(FileLocation & "new_name.xls")
set fs=nothing
Main = DTSTaskExecResult_Success
exit function
Else
Main = DTSTaskExecResult_Failure
exit function
End If
End Function
===========================================
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment