How to check the given path is existing or not using sp_cmdshell

Hi All,
   I am passing one path to the stored procedure, before executing code i want to check whether the path is given existing or not .
By using sp_cmdshell we can know whether files are there are not but in case of my scenario i want to know the directory(folder) is existing or not because the source folder may be blank so it will not get the files there so stored procedure returning the
 File Not found as output.
following is the code i am trying to retrieve this please suggest any other way to solve it.
Create table #tableExists  (isValid varchar(255))
Declare @path varchar(255)='DIR "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA "/B'
INSERT INTO #tableExists 
EXEC xp_cmdshell @path
select * from #tableExists
Regards,
Niraj Sevalkar

You can try the other two undocumented extended stored procedures as well:
--EXEC master.dbo.xp_subdirs @pathName
EXEC Master.dbo.xp_fileexist @pathName
EXEC Master.dbo.xp_DirTree @pathName,1

Similar Messages

  • [req] how to check whether given oracle table exist or not + C#

    Hi,
    All.
    Actually i m creating a program using C# which connects to the database (oracle) and checks for the given table "OPC_GROUP". if the table doesnt exists then it creates the table else it updates all field with provided values
    code
    cmd.CommandText = "SELECT tname from tab where tname = 'OPC_GROUP'";
    cmd.CommandType = CommandType.Text;
    int length = cmd.ExecuteNonQuery();
    if (cmd.ExecuteNonQuery() >0)
    MessageBox.Show("Table does exist");
    else
    MessageBox.Show("Table doesnt exist");
    But this code return "TABLE DOESNT EXIST" though table is already created
    What i m doing wrong???
    Please help..........
    Thnx in advance

    Try this..
    cmd.CommandText = "SELECT count(*) from tab where tname = 'OPC_GROUP'";
    cmd.CommandType = CommandType.Text;
    string strnum = cmd.ExecuteScalar().ToString();
    if (strnum!="0")
    MessageBox.Show("Table does exist");
    else
    MessageBox.Show("Table doesnt exist");
    Hope it helps,
    Greg

  • I get the error "the given path's format is not supported report" when trying to edit a Report from SharePoint 2013 is SSDT 2012

    I downloaded a copy into my project and I get these errors when I try to Preview

    Have a look at these links please:
    Convert existing project the given path's format is not supported
    Unable
    to open Project File of SSRS 2008 into Visual Studio 2012
    sqldevelop.wordpress.com

  • How to rename the SharePoint Document Library existing file name using Web service

    Hi,
    How to rename the SharePoint Document Library existing file name using SharePoint Web service.
    Is it possible. How could i do it?
    Thanks & Regards
    Poomani Sankaran

    Hi,
    Lists.UpdateListItems Method
    would be helpful for your requirement.
    Here is a blog with code demo for your reference:
    http://blogs.msdn.com/b/knowledgecast/archive/2009/05/20/moss-using-the-list-web-service-to-rename-a-file.aspx
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • How to check the jms Queue is persistance or not in jboss application serve

    hi,
    i am using jboss as application server for jms and database is postgres.For an message store i am using the "*database store*".while starting the jms adding queue it is adding the messages to the jms queue after starting the jms receiver the datas are received sucessfully....afte some 10 to 13 hours i am getting java.lang.OutOfMemoryError in jms..so i checked the postgres table space.Table space is increased gradually...I think that the after receiver received that message the messages are not deleted in the database.how to debugg the the secnario in jboss as wel as in database.....how to chaeck the queue is in persistance or not persistance...
    regards.
    naresh govindaswamy.

    Send a request to the server somehow, so that the server is aware of this. AJAX may be very useful in this if you want to do this asynchronously.
    its very urgently This is irrelevant information. That's your problem. We don't care less or more. Some users here will even refuse to help you if you're putting pressure.

  • How to set the File Path to run a javascript using Plugin Code?

    Hi All,
    Im new to Indesign Plugin Development.Can any one help me out with my problem.
    What i want to do is to run a javascript using Plugin Code.When i went through this forum i was able to find out that i should use the IscriptRunner Class to automate this.I could also figure out that the Member Function to use is "CanHandleFile" &"RunFile".
    The first parameter in CanHandleFile & RunFile Member Function is to specify the path of the JavaScript File i suppose!I could also find out that IDFile has to used to set the file path Information.
    But im clueless how to set the Javascript FilePath using IDFile.Can any one help me how to do this?Any Code Snippets Please?
    Waiting for reply.
    Thanks
    myRiaz

    Hi,  Andreas<br /><br />  Can you explain this in detail? I found it in your post before.<br /><br />  The content of elements are returned through the Characters callback function:<br /><br />From ISaxContentHandler.h:<br /><br />/**<br />        Receives character data<br /><br />The parser will call this method to report each chunk of<br />        character data. SAX parsers may return all contiguous<br />        character data in a single chunk, or they may split it into<br />        several chunks. But all characters in any single<br />        event must come from the same external entity so the<br />        Locator provides useful information.<br /><br />Note some parsers will report whitespace using the<br />        IgnorableWhitespace() method rather than this one (validating<br />        parsers must do so).<br /><br />@param Chars The characters from the XML document.<br />        */<br />virtual void Characters(const PMString& chars) = 0; <br /><br />  What i have done is implement my own SAXContentHandlerServiceBoss, and in my file XXXSAXContentHandler.cpp, I override the fonctions StartElement, EndElement, and Characters() like below: I add the PMString xmlData to collect the file content:<br /><br />class XXXSAXContentHandler : public CSAXContentHandler<br />{<br />void XXXSAXContentHandler::Characters(const WideString& chars)<br />{<br />xmlData.Append(chars);<br />}<br /><br />void XXXSAXContentHandler::StartElement(const WideString& uri, const WideString& localname, const WideString& qname, ISAXAttributes* attrs)<br />{<br />xmlData.Append("<"); xmlData.Append(localname); xmlData.Append(">");<br />}<br />void XXXSAXContentHandler::EndElement(const WideString& uri, const WideString& localname, const WideString& qname)<br />{<br />xmlData.Append("</"); xmlData.Append(localname); xmlData.Append(">");<br />}<br /><br />}<br /><br />and in my program, I use the code below to call the fonction I overrided, but I dont know how I can get the String xmlData I defined in the XXXSAXContentHandler.cpp<br /><br />InterfacePtr<IK2ServiceRegistry> serviceRegistry(gSession, UseDefaultIID());<br /><br />InterfacePtr<IK2ServiceProvider> xmlProvider(serviceRegistry->QueryServiceProviderByClassID(kXMLParserService, kXMLParserServiceBoss));<br /><br />InterfacePtr<ISAXServices> saxServices(xmlProvider, UseDefaultIID());<br />InterfacePtr<ISAXContentHandler> saxHandler(::CreateObject2<ISAXContentHandler>(kXXXSAXContentHandlerServiceBoss));<br />saxHandler->Register(saxServices);<br />bool16 parseFailed = saxServices->ParseStream(readStream, saxHandler);<br /><br />Can you give me any help?<br /><br />Thanks and regards!

  • How to check the size of flash memory that are used by each applications ?

    I'm using yxplayer as secondary media player.
    2 weeks ago, this program always fails to start up.
    So, I have uninstalled this program and reinstalled newer version.
    After reinstallation, it works well. But all the video clips that I have
    Copied to this application have gone away... And It seems the
    Flash memory that was used by older version did not returned
    To free space.
    Is there any tool to check the usage of internal flash of ipad in detail ?

    Hi,
    Is there any tool to check the usage of internal flash of ipad in detail ?
    Not memory, but storage space.
    Connect your iPad to your computer. Launch iTunes. Select the Summary tab. Storage space available at the bottom of the iTunes page.
    iOS devices do not support Flash.
    Carolyn

  • HT1923 In a hurry, I purchased or downloaded an application, now how to uninstall the same if I found it not useful.  Is deleting the icon sufficient from the screen of mobile phone? Please suggest.

    In a hurry, if I have purchased or downloaded any application, can I uninstall it completely if I found it not useful.  Is deleting I-con from the mobile screen sufficient? Please suggest. 

    Sorry, but what sort of "application" are you referring to, and on what system or device?

  • How to check if a file already exists or not

    javax.swing.filechooser.FileFilter filter = new FileNameExtensionFilter("CSV Files","csv");
                   final JFileChooser fileSelect = new JFileChooser();
                   fileSelect.addChoosableFileFilter(filter);
                   int action = fileSelect.showSaveDialog(JFrame)
                   try{
                        if (action == JFileChooser.CANCEL_OPTION)
                             return;
                        else if (action == JFileChooser.APPROVE_OPTION)
                             SwingUtilities.invokeLater(new Runnable()
                                  public void run()
                                       file = fileSelect.getSelectedFile();
                                       JOptionPane.showMessageDialog(null,file);
                                       if (!file.exists())
                                            JOptionPane.showMessageDialog(null,file.isDirectory());
                                       //fetches the file name from the file name filed in the GUI
                                       final String fileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
                                       if(!fileName.endsWith(".csv"))
                                            //appends the file type to the fetched filename
                                            ((BasicFileChooserUI)fileSelect.getUI()).setFileName(fileName + ".csv");
                                       final String newFileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
                                       //replace the oldfile with filename.csv
                                       String csvFile = file.getPath().replace(file.getPath().substring(file.getPath().lastIndexOf('\\') + 1,file.getPath().length()),"");
                                       file = new File(csvFile.concat(newFileName));
                                       if(file.exists())
                                            JOptionPane.showMessageDialog(null,file);
                                            int response = JOptionPane.showConfirmDialog (null,
                                                      "Overwrite existing file?","Confirm Overwrite",
                                                      JOptionPane.OK_CANCEL_OPTION,
                                                      JOptionPane.QUESTION_MESSAGE);
                                            if (response == JOptionPane.CANCEL_OPTION)
                                                 return;
                                            else
                                                 try
                                                      writeToFile();
                                                 catch (IOException e)
                                                      e.printStackTrace();
                                       else
                                            try
                                                 writeToFile();
                                            catch (IOException e)
                                                 e.printStackTrace();
                   catch(Exception e)
                        e.printStackTrace();
                   }

    Thank u very much
    I got the solution for it
    if(ae.getActionCommand().equals("Export"))
                   data= new Vector();
                   data.addAll(tabData);
                   javax.swing.filechooser.FileFilter filter = new FileNameExtensionFilter("CSV Files(*.csv)","csv");
                   final JFileChooser fileSelect = new JFileChooser();
                   fileSelect.addChoosableFileFilter(filter);
                   int action = fileSelect.showSaveDialog(MainFrame.getMainFrame());
                   try{
                        if (action == JFileChooser.CANCEL_OPTION)
                             return;
                        else if (action == JFileChooser.APPROVE_OPTION)
                             SwingUtilities.invokeLater(new Runnable()
                                  public void run()
                                       file = fileSelect.getSelectedFile();
                                       //fetches the file name from the file name filed in the GUI
                                       final String fileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
                                       if(!fileName.endsWith(".csv"))
                                            //appends the file type to the fetched filename
                                            ((BasicFileChooserUI)fileSelect.getUI()).setFileName(fileName + ".csv");
                                       final String newFileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
                                       //replace the oldfile with filename.csv
                                       String csvFile = file.getPath().replace(file.getPath().substring(file.getPath().lastIndexOf('\\') + 1,file.getPath().length()),"");
                                       JOptionPane.showMessageDialog(null,csvFile);
                                       if (csvFile.endsWith("\\" + "\\"))
                                            csvFile = csvFile.concat(fileName.concat("\\"));
                                       file = new File(csvFile.concat(newFileName));
                                       if(file.exists())
                                            int response = JOptionPane.showConfirmDialog (null,
                                                      "Overwrite existing file?","Confirm Overwrite",
                                                      JOptionPane.OK_CANCEL_OPTION,
                                                      JOptionPane.QUESTION_MESSAGE);
                                            if (response == JOptionPane.CANCEL_OPTION)
                                                 return;
                                            else
                                                 try
                                                      writeToFile();
                                                 catch (IOException e)
                                                      e.printStackTrace();
                                       else
                                            try
                                                 writeToFile();
                                            catch (IOException e)
                                                 e.printStackTrace();
                   catch(Exception e)
                        e.printStackTrace();
    Message was edited by:
    vijaysforum

  • How to check the OEM  agent is running or not

    Hi ,
    My OEM agent is keep on going down, I would like to receive an alert, when my agent is down.
    My Versions are "Oracle Enterprise Manager Cloud Control 12c Release 2"
    Thanks
    Reddy

    See if this helps,
    How To Configure Notification Rules in 12C Enterprise Manager Cloud Control ? Doc ID 1368036.1
    Aman....

  • HELP !!! How to check the size of an object in Photoshop ?

    Hello,
    I'm using Photoshop CS 3 to design a website. I used several shapes such as rectangle, line or ellipse of different size. Probably it is a stupid question but I don't know how to check the size of an existing rectangle. I tried free transform tool that selects my rectangle but doesn't show its size. Then I made a selection with rectangular marquee tool but I see nowhere the size of the selected area.
    If you know the name of such a tool please help me !
    Have a nice day !

    Web images are all pixels. View at 100% at pixel view. that is your exact size

  • How to check the number of licences for ODI

    Hi,
    I would like to know , how to check the number of licences exists for my current OID.
    ODI Version: 11.1.1

    ODI licensing is similar to Oracle DB licensing. Its licensed by the number of cores in your target database.
    So, count the number of CPUs in your target box. Multiply them by the core factor (x86 vs sparc, etc) and then match with the paperwork you have :D

  • HOw to create a text file in the given path and delete it after the use?

    Hi all,
    I am trying to create a text file at the given path and delete the created file after the use.
    I am using following code.:
    import java.io.*;
    // write binary data as characters
    public class RanIO {
                                            public static void main(String f[])
                                                      // First illustrate append
                                                      String lineSep = "\n";
                                                      try {
                                                                     File temp= new File("C:/Ash","cute.txt");
                                                      boolean ch=temp.createNewFile();
                                                      if(ch)
                                                           System.out.println("file created");
                                                      else
                                                      System.out.println("file Not created");
                                                      //writing to file
                                                 /*     PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
                                                      p.print("Emp NO");
                                                      p.close();*/
                                                                // Open fileWriter in append mode
                                                                               FileWriter fos = new FileWriter(temp, true);
                                                                               BufferedWriter bw = new BufferedWriter(fos);
                                                                               PrintWriter pw = new PrintWriter(fos);
                                                                               double d=550;
                                                                          // lineSep = System.getProperty("line.separator");
                                                                          pw.print("Hello");
                                                                          //pw.print( lineSep );
                                                                          pw.print( d );
                                                                          pw.close();
                                  boolean det=temp.delete();
                                                 if(det)
                                                      System.out.println("File deleted");
                                                 else
                                                      System.out.println("File not deleted");
                                                 } catch (IOException ioe)
                                                                System.out.println( "Append IO error:" + ioe );
    My problem:
    1)
    I am not able to write to the file. I want to know, where i am going wrong.
    It is giving error message like
    "Canot resolve Symbol: temp,"
    But, FileWriter Constructor should accept a File type parameter.
    here temp is a file parameter.
    If i am not using file=new file();
    i can't delete the file after the use. i.e if i use
    PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter("cute.txt",true)));
    how can i delete cute.txt after the use?
    2)
    I am not able to write to the text file. file is created but, a blank file.
    "Hello" is not written into the text file.
    can anyone help me in this regard
    Thanks in advance
    Ashvini

    Thank you Ram,
    But, i want to create a text file in Append mode.
    for that i used
    FileWriter fos = new FileWriter(temp,true); But, it is not accepting FileWriter constructor in
    this format. if i use
    FileWriter fos = new
    FileWriter("c:/ash/cute.txt",true); it works fine. !!!!!Here's the javadoc
    public FileWriter(File file,
    boolean append)
    throws IOExceptionConstructs a FileWriter object given a File object. If the second argument is true, then bytes will be written to the end of the file rather than the beginning.
    Parameters:
    file - a File object to write to
    append - if true, then bytes will be written to the end of the file rather than the beginning
    Throws:
    IOException - if the file exists but is a directory rather than a regular file, does not exist but cannot be created, or cannot be opened for any other reason
    Since:
    1.4
    Are you using jdk.13 or lower ?
    >
    ONe more doubt, Does flush method deletes a file?
    if not, then i need to use
    File temp=new File("c:/ash/cute.txt");
    FileWriter fos = new FileWriter(temp,true); //which
    is again a problem
    if(temp.delete())
    out.println("File is deleted");
    }I don't know whether i am taking it wrong ! or
    anything wrong with my coding ! but, after creating
    and writing data into a text file. I must delete it
    as it contains confidential informations.
    Regards,
    Thanks.'flush' writes to a file immediately. Else you should explicitly call 'flush' to write contents from buffer to underlying source.
    javadoc again
    PrintWriter
    public PrintWriter(Writer out,
    boolean autoFlush)Create a new PrintWriter.
    Parameters:
    out - A character-output stream
    autoFlush - A boolean; if true, the println, printf, or format methods will flush the output buffer
    cheers,
    ram.
    Question; What do you gain by opening a file, writing to it and deleting it in the same program ?

  • How to get the absolute path of a file from the local disk given the file n

    how to get the absolute path of a file from the local disk given the file name

    // will look for the file at the current working directory
    // this is wherever you start the Java application (cound be C: and your
    // application is located in C:/myapp, but the working dir is C:/
    File file = new File("README.txt"); 
    if (file != null && file.exists())
        String absolutePath = file.getAbsolutePath();

  • How to check the verity version in our PeopleSoft Installation?

    How to check the verity version in our PeopleSoft Installation? I am not sure if the verity is installed or not and also if installed what is the version?

    yes. it says the version is 5.0.1
    Is there any difference in installation or configuration when the app and web server are in same machine and when the app and web server are installed in different servers?
    ============================================
    D:\fs840\webserv\peoplesoft>mkvdk
    mkvdk - Verity, Inc. Version 5.0.1 (_nti40, Jul 23 2004)
    Usage: mkvdk [<option>...] <filespec>...
    Where <option> can be a VDK switch, or any of:
    -about Show the collection's about resources
    -autodel Delete bulk insert file when no longer needed
    -backup <dir> Specify collection backup location
    -bulk Submit bulk insert file(s)
    -charmap <name> Specify the character map to VDK
    -collection <path> Specify the collection (required)
    -create Create the collection
    -credentials <user> Specify user[:passwd][:domain][:mailbox]
    -datapath <path> Specify VDK datapath
    -datefmt <fmt> Specify date format to VDK
    -debug Enable debugging output
    -delete Delete documents
    -description <desc> Set the collection's description
    -diskcache <num> Set VDK's disk cache size (kbytes)
    -extract Extract field values from text
    -help Print this usage information
    -insert Insert documents (default)
    -locale <locale> Specify the locale to VDK
    -logfile <file> Save output in a log file
    -loglevel <num> Set the VDK output level for the log
    -mailboxes This option is depracated. Use the credentials option inste
    ad
    -maxfiles <num> Set VDK's maximum number of open files
    -maxmemory <num> Set VDK's maximum memory usage (kbytes)
    -mode <mode> Set the indexing mode
    -modify Modify fields using field/value pairs from a bulkfile
    -nohousekeep Disable housekeeping
    -noindex Disable indexing
    -nolock Turns off locking (dangerous)
    -nooptimize Disable optimizations
    -nosave Don't save collection work list
    -noservice Prevents servicing of submitted work
    -nosubmit Don't submit work to VDK
    -numdocs <num> Number of documents to insert from bulk insert file(s)
    -numpages <num> Synonym for diskcache for backward compatibility
    -offset <num> Specify offset into bulk insert file(s)
    -online Flag for online Bulk Modify
    -optimize <spec> Optimize the collection
    -outlevel <num> Set the VDK output level
    -persist Service the collection forever
    -purge Remove all documents from collection
    -purgeback Purge in the background
    -purgewait <secs> Specify delay before purge
    -quiet Suppress all non-error messages
    -repair Repair the collection
    -servlev <spec> Advanced option for overriding service level
    -sleeptime <secs> Interval between service calls for persist
    -style <dir> Specify style directory for create
    -submit Synonym for noservice for backward compatibility
    -synch Perform work synchronously
    -topicset <path> Specify VDK topic set
    -update Update documents
    -vdkhome <path> Specify VDK home
    -verbose Output more information
    -words Build word assist list
    -wordindex Build word assist index
    The <spec> for -optimize is a hyphenated string of:
    maxmerge Perform maximal merging of partitions
    squeeze Recover space from deleted documents
    vdbopt Build optimized VDB's
    spanword Create word list spanning all partitions
    ngramindex Create ngram index into spanning word list
    maxclean Really clean (not for read-write)
    readonly Make the collection read-only
    tuneup Fully optimize for read-write use
    publish Fully optimize for read-only use
    The <spec> for -servlev is a hyphenated string of:
    search Enable search and retrieval
    insert Enable adding and updating documents
    optimize Enable opportunistic collection optimization
    assist Enable building of word list
    housekeep Enable housekeeping of unneeded files
    delete Enable document deletion
    backup Enable backup
    purge Enable background purging
    repair Enable collection repair
    dataprep Same as search-index-optimize-assist-housekeep
    index Same as insert-delete
    Error: must specify collection
    mkvdk done
    D:\fs840\webserv\peoplesoft>

Maybe you are looking for

  • How to access a Progress DB in a DotNet application?

    Hi, I'm new to this kind of database access...... I need to read records from a Progress database into my VB .Net application. The application itself uses database MS-SQL( It's a DotNetNuke - DNN portal). I can access the Progress db within an Excel

  • Problema with strings as parameters

    I'm facing a curious problem. I have already downloaded a few classes that encode special characters into html entities. All of them receive a string paramter and return the encoded string. The problem is that if i pass an actual string as paramater,

  • How do add a toolbar to the yahoo firefox? I have a program already downloaded. I need help adding the toolbar.

    I use Roboform and after I downloaded Yahoo Firefox it no longer appeared as one of my toolbars. How do I get it back? I need it for those sites I visit once and a while and filling out forms. I'm using MS 8.1. Thanks.

  • IOS 8.3 is not downloading/updating

    My iPad 2 is not downloading iOS 8.3 (I've tried 3 different times). Each time I've tried, it becomes a black screen that alternates with a black screen with white-apple logo.....for HOURS. A couple days ago when I tried, it was over 24 hours that it

  • AW01N Asset Comparisons

    Dear experts, AW01N Asset Comparisons AUC   Asset value fiscal year 2007 is 4,245,383.00. Next year 2008 fiscal year start Asset value 4,245,383.00 and Change value is 77,175,945.48. 2008 fiscal year end value 81,421,328.48. Next year 2009 fiscal yea