Copying filenames to SQL Table | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Copying filenames to SQL Table

Hello everyone, I have 200 excel files in a folder C:Company and i want these filenames to be in a table.
So as to do this task, I used a batch file which transfers the filenames to a text file and the data from that text file is then transfred to the SQL table ExcelFileNames. It works fine for the files with filename in english. But there are som files whoes filenames contain Europian characters. When I run the batch file, these filenames are not transfered as it is, the europian charactres are converted into commas. becaus of which i canot access the file. Does any one know how i can copy the filnames directly to SQL server? If you have any idea abt this pls do let me know Thanks in advance Regards!
Pallavi

Hi there Sorry for the inconvenience , but later i found out the way to do that. Now i can dirctly transfer the filenames from source to a table in sql, without any text files or batch files. Pallavi

How did you do it? [<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />] It’s good to now that you found an answer. If you post it though, it might help other people looking for answers.<br /><br />MeanOldDBA<br />[email protected]<br /><br />When life gives you a lemon, fire the DBA.

the method that I use for this is create table t_files( filename varchar(255) null ) insert into table t_files
exec sp_cmdshell ‘dir c:company /b /a-d’
Cheers
Twan

Small modification on Twan’s code create table t_files( filename varchar(255) null )
insert into table t_files
exec Master..xsp_cmdshell ‘dir c:company /b /a-d’ Madhivanan Failing to plan is Planning to fail
oops typing to quick again… thanks Madhivanan Cheers
Twan
]]>