Jan Mishkin
asked on
FTP file list and cmd shell
I want to use vb OR Ms SQl to get a list of filenames from a remote sql server. I just want the file names, not the files. We've been doing this with the vb object FtpClientConnection but it does not work with several of our new partners so we're looking for an alternative. I figure the most fool proof way is just to run a cmdshell from sql or VB but I can't find anything that just retrieves a list of filenames.
Whats a good solution??
Whats a good solution??
See if this helps. http://www.mssqltips.com/tip.asp?tip=1641
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Will try both soon.
Thanks a lot
Thanks a lot
ASKER
gdewrell:
We already use a similar solution. We need to switch to a command line solution as an alternative because somethings not right with one of our clients using SSIS
ModuleKev::
Your solution looks good but I'm stuck at
Exec master..xp_cmdShell 'bcp "select * from MyDB.dbo.ftpinf" queryout C:\test.txt -c -T'
C:\test.txt is @filename
the bcp runs fine. No errors but also no file is created?!!?
heres the result
NULL
Starting copy...
NULL
4 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 1 Average : (4000.00 rows per sec.)
NULL
I know this is a seperate concern but I can't get to the end of your solution because of it. Any ideas?
Thanks
We already use a similar solution. We need to switch to a command line solution as an alternative because somethings not right with one of our clients using SSIS
ModuleKev::
Your solution looks good but I'm stuck at
Exec master..xp_cmdShell 'bcp "select * from MyDB.dbo.ftpinf" queryout C:\test.txt -c -T'
C:\test.txt is @filename
the bcp runs fine. No errors but also no file is created?!!?
heres the result
NULL
Starting copy...
NULL
4 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 1 Average : (4000.00 rows per sec.)
NULL
I know this is a seperate concern but I can't get to the end of your solution because of it. Any ideas?
Thanks
Sorry been off ill...
Literally running the same code as you've posted (bar table selection) works for me..
Run Exec master..xp_cmdshell 'dir c:\*.*'
In the results can you see your file? I am just making sure that you are aware that the file should be created on the machine sql is running on, not the machine you're working off. I used to do break down and recovery and it's often the simpliest thing you don't think of that is the root cause.
If not:
If you're running on later than Windows 2003, you may find it's an issue outputting to the root of a drive. Create a folder on the root and then try to output to that instead.
Literally running the same code as you've posted (bar table selection) works for me..
Run Exec master..xp_cmdshell 'dir c:\*.*'
In the results can you see your file? I am just making sure that you are aware that the file should be created on the machine sql is running on, not the machine you're working off. I used to do break down and recovery and it's often the simpliest thing you don't think of that is the root cause.
If not:
If you're running on later than Windows 2003, you may find it's an issue outputting to the root of a drive. Create a folder on the root and then try to output to that instead.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yup. It worked when I explicitly defined the Server using the -S tag. Now on to the next steps. Thanks
ASKER
Good Job.