Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Server 2005/2008

Posted on 2012-04-03
5
Medium Priority
?
504 Views
Last Modified: 2012-04-30
Here is the sql i used.
--Create the table to store file list
CREATE TABLE myFileList (FileNumber INT IDENTITY,FileName VARCHAR(256))
--Insert file list from directory to SQL Server
DECLARE @Path varchar(1024)
SET @Path = 'dir C:\ExcelFiles'
DECLARE @Command varchar(1024)
SET @Command = @Path + ' /A-D  /B'
INSERT INTO myFileList
EXEC MASTER.dbo.xp_cmdshell @Command
--Check the list
SELECT * FROM myFileList
GO
--Clean up
DROP TABLE myFileList
GO

When i execute above sql, I get file not found.
I'm sure i did execute same or similar sql below and always worked.
Not sure why it isn't working now.

FYI: C:\ExcelFiles is local to workstation not on sql server and has bunch of excel files.
Maybe it's looking for something on sql server ????
0
Comment
Question by:onebite2
[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
5 Comments
 
LVL 22

Expert Comment

by:pivar
ID: 37803784
Hi,

The command is executed on the sql server. So what you're seeing is a dir on your sql servers c: drive not your workstation drive.

/peter
0
 
LVL 5

Expert Comment

by:rtay
ID: 37803797
Map a drive on the sql server to the computer your looking for.  then you can set your path to M:\ExcelFiles.  (if M is the drive letter you choose to map the workstation to.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 37804417
Map a drive on the sql server to the computer your looking for.  then you can set your path to M:\ExcelFiles
Have you ever tried that?  Reason I ask is because you may find that since SQL Server is running as service it will not recognize any mapped drives.  Then of course you have the small detail of security, but that is another story...
0
 

Author Comment

by:onebite2
ID: 37806450
Sql Server is installed locally on my workstation. How would i map a drive on the sql server to the computer your looking for.. I think i kinda have an idea if sql server installed on different or remote server but what if a sql instance exists locally.

I did different paths on c/d drives, sometimes i keep getting messages like "file not found", sometimes "Access is denied" and sometimes "The system cannot find the path specified"
Does it tell you something????

Again my question "How would i map a drive on the sql server to the computer your looking for"
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 400 total points
ID: 37808540
Don't map a drive.  Instead try using a UNC Path as in \\remoteserver\Whatevershare.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

719 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