Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count files with SQL

Status
Not open for further replies.

batteam

Programmer
Sep 12, 2003
374
US
I would like to use SQL to count the number of files in a folder. Does anyone have the SQL commands to do this, if possible? Thanks in advance for any help you can offer.
 
drop table #test

CREATE TABLE #test (
t2 varchar( 255),
)

INSERT INTO #test
exec xp_cmdshell 'dir /b d:\'
go

select *
from #test
where t2 is not null

select count(*)
from #test
where t2 is not null

Simi
 
ps... xp_cmdshell is not enabled by default so you will have to enable it and have permissions to run it.

Just Google it for those instructions.

Simi

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top