Solved

Reading file properties in SQL Server 2005 !!

Posted on 2007-11-28
4
1,039 Views
Last Modified: 2012-06-27
Hi,

I have a file (ABC.txt) file in C:\Temp folder. I want to read this file properties and place them in a SQL Server database table. Can you please let me know how can i read its properties ?

Appreciate your time and patience !

Thanks
0
Comment
Question by:kishore_peddi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Yveau earned 500 total points
ID: 20368204
When you access another subsystem, you cannot do that by regular SQL code.
So what you might need here (and that is really not a good idea from security standpoint) is use the xp_cmdshell procedure. That way you can run 'DOS' commands and do an 'attrib' or 'dir' of the files.

First enable xp_cmdshell (off by default)

Hope this helps ...

sp_configure 'show advanced options',1
go
reconfigure
go
 
sp_configure 'xp_cmdshell',1
go
reconfigure
go
 
exec xp_cmdshell 'dir C:\'
 
sp_configure 'xp_cmdshell',0
go
reconfigure
go
 
sp_configure 'show advanced options',0
go
reconfigure
go
 
 
--

Open in new window

0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 20370677
You can write a vb.Net console app and link it to a stored proc and do it that way also.
0
 

Author Comment

by:kishore_peddi
ID: 20371782
Yveau,

Can you just clarify one point please ?

use sample  -- (sample - is my database)
go

sp_configure 'show advanced options',1
go
reconfigure
go
 
sp_configure 'xp_cmdshell',1
go
reconfigure
go
 
exec xp_cmdshell 'dir C:\'  -- (xp_cmdshell => In which database this is residing ? in MASTER or sample)
go            
 
sp_configure 'xp_cmdshell',0
go
reconfigure
go
 
sp_configure 'show advanced options',0
go
reconfigure
go
0
 
LVL 18

Expert Comment

by:Yveau
ID: 20383871
master
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question