Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Get a Filename and put into a variable in SQL Server Query Analyzer

Posted on 2007-11-28
Medium Priority
Last Modified: 2012-05-05
Is there a way to get a filename from the windows directory and put that name into a variable using xp_cmdshell commands ?

ex. c:\folder\test.csv

I just want the part of the pat that has test.csv. is it possible to collect that information in a stored procedure ?
Question by:Auerelio Vasquez
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
  • 3
  • 2

Author Comment

by:Auerelio Vasquez
ID: 20367675
That solution is a little more than i need. I really need to go and find out what a filename is in a directory, and pass it to the variable.....
LVL 31

Expert Comment

by:James Murrell
ID: 20367776

Accepted Solution

Auerelio Vasquez earned 0 total points
ID: 20367855
where is the part about xp_cmd shell in this blog ?

Author Comment

by:Auerelio Vasquez
ID: 20414513
is there anything else you can suggest ? these weren't helpful

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

650 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