?
Solved

Reading file properties in SQL Server 2005 !!

Posted on 2007-11-28
4
Medium Priority
?
1,047 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

649 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