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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Loop to list file in C drive

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2010-05-10 : 16:49:53
Is it possible to code a loop to read all files' name and then insert into a SQL table?
For example, I need to read all files' name (no extension) in c:\temp\ and then insert into a SQL table tAllFiles.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-05-10 : 16:54:36
CREATE TABLE SomeTable (Column1 varchar(500))

INSERT INTO SomeTable
EXEC master.dbo.xp_cmdshell 'dir C:\temp\*.* /B'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -