Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 ftp on error re try
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gangadhara.ms
Aged Yak Warrior

India
549 Posts

Posted - 01/28/2013 :  02:37:11  Show Profile  Reply with Quote
Hi,
I am using the below command to download the file from FTP. But i want to ensure if there is no files exist we need to alert a TEAM saying its not there.How can we achieve this ??

SET @cmd = 'del E:\ARK\AT\cmds.txt /Q'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo username_XXX>> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo password_YYY >> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo lcd E:\ARK\AT >> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo cd /A/updates >> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo mget *' + dbo.AtDate() +'.* >> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'echo quit >> E:\ARK\AT\cmds.txt'
EXEC master..xp_cmdshell @cmd

SET @cmd = 'ftp -i -s:E:\ARK\AT\cmds.txt ftp.XXX.com'
EXEC master..xp_cmdshell @cmd



Thanks,
Gangadhara MS
SQL Developer and DBA

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 01/28/2013 :  03:36:42  Show Profile  Reply with Quote
do a dir on file pattern and take the count and check if its >0 before you do above

wrap the entire code in a batch file

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

gangadhara.ms
Aged Yak Warrior

India
549 Posts

Posted - 01/28/2013 :  21:40:22  Show Profile  Reply with Quote
thanks visakh for suggestion

could you pls some script to count the files ..i am sorry i am not much versed with ftp commands.

Thanks,
Gangadhara MS
SQL Developer and DBA

Edited by - gangadhara.ms on 01/28/2013 22:28:54
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000