Transact SQL :: Check If UNC Path Exists (It Is Folder Not File)

Oct 29, 2015

Usual way to check if file exists

DECLARE @File_Exists INT 
EXEC Master.dbo.xp_fileexist 'serverBSQL_Backupfile.bak', @File_Exists OUT 
print @File_Exists

1

And if check folder, can use "nul", but it doesn't work for UNC path

DECLARE @File_Exists INT 
EXEC Master.dbo.xp_fileexist 'serverBSQL_Backup
ul', @File_Exists OUT 

print @File_Exists
0

If use xp_subdirs like:

 EXEC master.dbo.xp_subdirs 'serverBSQL_Backups'

If the folder doesn't exists,

Msg 22006, Level 16, State 1, Line 3
xp_subdirs could not access 'ServerBSQL_Backups*.*': FindFirstFile() returned error 67, 'The network name cannot be found.'

How to check if UNC folder exists in Backup? in my code I want to check if the unc folder exists before doing backup, the unc path is retrieved from other table or backup history.

View 8 Replies


ADVERTISEMENT

SQL Server Admin 2014 :: Check If UNC Path Exists (It Is Folder - Not File)

Oct 29, 2015

usual way to check if file exists

DECLARE @File_Exists INT
EXEC Master.dbo.xp_fileexist 'serverBSQL_Backupfile.bak', @File_Exists OUT
print @File_Exists
1

And if check folder, can use "nul", but it doesn't work for UNC path

DECLARE @File_Exists INT
EXEC Master.dbo.xp_fileexist 'serverBSQL_Backupul', @File_Exists OUT
print @File_Exists
0

If use xp_subdirs like:

EXEC master.dbo.xp_subdirs 'serverBSQL_Backups'

If the folder doesn't exists, Msg 22006, Level 16, State 1, Line 3 xp_subdirs could not access 'ServerBSQL_Backups*.*': FindFirstFile() returned error 67, 'The network name cannot be found.'

how to check if UNC folder exists in Backup? in my code I want to check if the unc folder exists before doing backup, the unc path is retrieved from other table or backup history.

View 6 Replies View Related

Help Please (Check File Exists/ Archive File/ Check If File Empty)

Mar 10, 2008



Hello World,

I'm new to SSIS and would like a little assistance getting started, if possible...


Here is what I want to do:


Check if file exist (C:DTS UpgradeFilexxx.txt) --->

Archive file (C:DTS UpgradeArchive) --->

Check if file has data (true or false)


AND/OR

If there are any good website that have good direction, let me know


Thanks in advance for your help!!!

View 5 Replies View Related

Transact SQL :: Check If There Are Files In Folder

Jul 20, 2015

I'm wondering if its possible to return the number of files in a folder suing something like DIR command.I'm wanting to do something like, If count(DIR) >0 then do something

else End
exec master.dbo.xp_cmdshell
'dir C:Test'

View 2 Replies View Related

Transact SQL :: Verify Complete Restore Path (check For Missing Files)

Jul 29, 2015

In SQL Studio, I can go to the restore window and the click "verify backup media". This would check the restore plan listed in this window and check if some of the file are missed.Is there any way to reach this with TQSL? I know there is a "restore verify" command, but this will only verify one backup/file and not the complete restore path. I'm looking for a TSQL solution which is able to control that all necessary backup files are still present on the file System and not moved or deleted (e.g through cleanup task).

View 3 Replies View Related

SQL Server 2008 :: Checking Files In A Shared Path If Folder Or File?

Jun 3, 2015

I wrote the below script to print all folders and files located in the share path. How to extend my script to mention by adding another column whether the file is a folder/file , sort of 0 or 1.

declare @chkdirectory1 varchar(4000) = 'shared_pathfolder';
declare @finalserver3 varchar(4000);
create table #tmp (directory_name varchar(4000))
SET @finalserver3 = '''"DIR ' + @chkdirectory1 + ' /B"''';
--select @finalserver3
--SELECT @finalServer
DECLARE @ExecCmd varchar(100)
--SELECT @ExecCmd = 'EXEC master.dbo.xp_cmdshell ' + char(50) + 'mkdir D:'+ CONVERT(varchar(8), getdate(), 112) + '' + char(50)
SET @ExecCmd = 'EXEC master.dbo.xp_cmdshell ' + @finalserver3
--SELECT @ExecCmd
exec(@ExecCmd)
drop table #tmp

View 0 Replies View Related

Check If A File Exists Using Sql

Oct 7, 2003

Is there is a piece for code ot sample code that can let me check if a file exists? Has any one done this before?

Thanks

View 2 Replies View Related

How To Check If A File Exists

Jul 25, 2006

Hi, can someone tell me how to check if a file exists. If it exists then i want to continue with the process and if it fails then send a mail to me.

Thanks in advane.

View 6 Replies View Related

Check If File Exists

Aug 21, 2006

In SSIS, I need an easy way to see if a file exists, and if not wait for it until a timeout period expires. Here are the options I've discovered, along with the issues I've had:

a) The File Watcher task from www.sqlis.com


This was my first attempt. The task works great, BUT only detects when there is a change on the file. If the file already exists, it keeps waiting which is not the behavior I need.
b) The WMI Event Task

There is very sparce documentation on this event and how to write a WQL query. There are numerous examples of monitoring a folder and if any files appear, cause an event to happen. I need to detect for a specific file. I found maybe one example of this using "PartComponent" but wasn't able to get the sytax right to make it work for me. I also need to access a remote file share using a UNC path (e.g. \servernamepathfile.txt) which I could not get to work.
c) Script Task using the File.Exists() method

I imported the System.IO namespace, and used a File.Exists(\servernamepathfile.txt) with actual success, but am not sure of the best way to continue to wait if the file is not found immediately. I also want to modularize this approach so I can wait for several files simultaneously so was thinking of implementing this script task as a package by itself to accept variables (filepath & timeout period) but need to know if anyone has had success with this approach.
I'm open to suggestions or ways to get options a) and b) to work for my needs.
Thanks!
Kory

View 13 Replies View Related

How To Check For A File Existence In A Folder In SSIS

Oct 26, 2007

I have a data flow task inside a foreach loop container which will take multiple excel files and load into a sql table. Once all the excel files are loaded into the table, then at the end one of the column gets updated using execute sql task. Now I am trying to check for a file existence, if the file is not present in the folder then the data flow task should not be executed. Any help is greatly appreciated, I am thinking of using file system task for this, but not exactly sure. Thanks in advance.

View 13 Replies View Related

Check If A File (pattern) Exists Using A Script Task

Dec 6, 2007

Hi,

I need to check if a file exists (using a filename pattern as the filename will be dynamic) in a directory.

I am trying to use the File.Exists() method in a Script Task. However, it does not allow me to do something like -
File.Exists("C:Files*.xls")
Or
File.Exists("C:Filesabc*.xls")



Any help on this?

Thanks in advance.

Regards,
B@ns


View 3 Replies View Related

SQL Server 2008 :: Check If File Exists Using Script Task

Mar 17, 2015

I need to create a script task in sql server 2008 R2 to check if a file exists in a directory. For example, to see if output.dat exist under c:results. If the file exists, then send out an email stating the file exists, if not then send out another email stating the file does not exists.I noticed there is a huge difference between the script task in sql 2005 and sql 2008 r2.

View 3 Replies View Related

I Want To Get The Root Appliation Path For Loading A File Which Is In My Root Folder Of Windows Application

Dec 4, 2007



hi
my application is applocation1 i kept a file in this folder i want to read it from application how can i get the path of that file in my application.

i want to read the file in my root folder excluding the bin path

Please any one know the answer let me know ..

thanks and regards
Ravishanker Maduri

View 1 Replies View Related

Integration Services :: SSIS WMI Event Watcher Check For New Folder In Existing Folder

Jul 2, 2015

I know a WMI event watcher can be used to watch for a new file being added to a folder. However, I need to check for new folders being added to an existing folder. I haven't been able to find a post on doing this. Is there a way in WQL to check for a new folder being added instead of a new file? I've used SQL for years, but am new to SSIS.

View 2 Replies View Related

Transact SQL :: Backup Database And A Folder From Some Program In One Bak File?

Jun 17, 2015

the idea is to put together a folder that is in some place in the computer, like "c:excel_fles" and the database full backup in a single .bak file, the database can be recovered with sql server management studio(but no the folder), the restoration of the program can be done with a program, I think it can be done with msdb, but I'm a little lost in the road.

View 4 Replies View Related

Get A SQL Backup Folder Path In Asp.net

Aug 2, 2007

 
Hi
 
Anyone knows , get a SQL Backup Folder Path in asp.net.Some Systems it displayed like D:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBackup and some Systems like E:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLBackup and etc. i need to get a path for backup programmatically.Please help me.
 
Tamil

View 1 Replies View Related

Folder Path Configuration

Mar 19, 2008

i have created one package which contains flat file source and flat file destin and corres conneciton mgrs.

i created configuration using package configurations with name config.dtxconfig.(while creating it i selected connection string under source file and destination file).

config.dtxconfig contains path as config value for source c:folderfilesourc.txt.and for destination c:folderfiledest.txt





But my req is we have to create another xml named as folderpath.xml should contain the path up to c:folder.for every package execution ssis should access this xml where it should find the folder.

if i want to change the name of folder (or ) move the folder i should change in folderpath.xml only wihout changing folder name in all configuration files.



can i do that.

if not give me alternate solution.plz guide me with clear explanation since i am novice to this tool

View 1 Replies View Related

How To Set The Path To The Reports Snapshots Folder?

Mar 15, 2007

We have a statutory requirement to keep 5 years of history, so I've checked the option in the Site Settings page in the Report Manager to "Keep an unlimited number of snapshots in report history". The drives are partitioned as follows:

C: -- OS; 20GB

D: -- Apps; 20GB

E: --Data: 160GB

I want to force the report history snapshots onto the data (E:) drive, but I can't figure out what setting will force them there. Can anyone tell me how to set the path to the reports snapshots folder?

View 1 Replies View Related

Remote Path Does Not Exists -error-FTP-SSIS

Mar 6, 2008

I am getting this error, when I try to access a directory in the remote path. Though the directory exists, I get this error.
550 CWD CMD FAILED : EDC5129I NO SUCH FILE OR DIRECTORY.

When I try to access through the remote login, I am able to see the directory as well as the files there. How to overcome this error. Is there any workaround for this.
Thanks.

View 1 Replies View Related

SQL Server 2008 :: Unable To Create Folder If Present Already In A Share Path

Jun 1, 2015

I'm, using my script to many location to create folder to save output files and if the folder is removed/not present it can create it without any noise. But the problem is, while I use the same sort of script to check if a folder is present in the sharedpath it will not create it to copy all bkp files from local to remote path works good, but if you delete the folder or rename the exisitng folder and if the below script tries to create the folder it created as "fILE", very interesting. Per IT team they have given SQL Server account the full rights to create/delete/alter folder/files.

Do I need to use seperate script or way to create / alter folders in the sharepath?

SET NOCOUNT ON
Declare @len INT, @i INT, @Left varchar(max), @right varchar(max), @SERVERNAME sysname,@finalServer sysname
declare @rc int, @dir nvarchar(4000)
DECLARE @cmd1 sysname, @cmd2 sysname, @cmd sysname;
Declare @extPAth varchar(max)

[Code] ....

View 5 Replies View Related

Reporting Services :: RDLs Present In SSRS Folder Path But Not Visible In Report Viewer URL?

Jun 9, 2015

I have an issue as to where only some reports are visible within Report Viewer url. But if I navigate to the path of the rdl's there are many more present that should be visible through Report Viewer. The client was recently upgraded, and I seem to have all out of box roles and permission levels yet can only see some of those reports, as if some were manually copied to this folder location at a later point and perhaps some user job needs to be run to reflect import those additional rdl's?

View 2 Replies View Related

Reporting Services :: Unable To Show Images From Folder By Reading Path From Database In SSRS Report

Apr 28, 2015

Basically i have 3 images capacity per record in my asp.net application. In there i am saving the image path with record id in database and image in my application folder.

Now i am creating SSRS Report in Report builder . In there i have taken one image control to show the images. In the Image properties in report builder i have chosen database under the select the image source field. then inside use this field i have chosen image url and in use this MIME Type i have selected image/jpeg. Now i have saved this report in report server folder.

Now while calling in .net web from through report viewer control. It is opening the report but wont showing the image.

View 2 Replies View Related

How To Check If Row Exists...

May 3, 2006

Hello,

I'm SQL Server 2005 newbie, could you be so kind and help me how to write the most efficient way stored procedure, which checks by PK if specified row exists, then updating the row, otherwise inserting new one.

Thank you for your kind help.

View 18 Replies View Related

Check If Record Exists

Feb 1, 2007

 Hello,I created the following SQL script to check if a record exists:IF (EXISTS (SELECT LevelName FROM dbo.by27_Levels WHERE LOWER(@LevelName) = LOWER(LevelName)))  Return (1)ELSE  Return (0)And I also found in a web page another solution:IF EXISTS(SELECT 1 FROM TABLENAME WHERE LevelName=@LevelName)  SELECT 1ELSE  SELECT 0- Which approach should I use?- Why "SELECT 1 FROM"?- And when should I use SELECT or RETURN?All I need is to know if the record exists ... nothing else.I will use this procedure on an ASP.NET 2.0 / C# web site.I am not sure if this important but anyway ...Thank You,Miguel

View 6 Replies View Related

Check If Record Exists

Dec 24, 2007

Hi,
 I was wondering if someone can help.
 In vb.net what is the best way to check if a record exists if you are using an sql data reader?
For my application I need to display a button control (make it visible on the page) if a record is available after executing my sql select statement.
cheers
Mark :)

View 3 Replies View Related

Check Id Exists In Sql Table?

Jan 17, 2008

Hi all,I am in the process of creating a page that checks to see if a particular user exists in the database and if it does then send to welcome.aspx if not then accessdenied.aspx.  The userid is requested from the query string.I have done some research and cannot find anything directly related, I have tried to add bits of code into what i think is the right place but I dont think what i am doing is correct. Can someone help and show me where my code is going wrong? Also is there a better/more efficient way to do what I am doing?Thanks in advance. default.aspx.csusing System;using System.Data;using System.Data.SqlClient;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class _Default : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        string UserID = Request.QueryString["uid"];        //string TransferPage;        if (UserID != null)                {            //initiate connection to db            SqlConnection objConnect = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString);            string sql = "SELECT COUNT(*) FROM members WHERE UserID = '" + UserID + "'";            SqlCommand query = new SqlCommand(cmd, test);            int count = (int)query.ExecuteScalar();            int aantal = -1; // some default value if can't insert record            if (count == 0) // no existing record for username            {                Server.Transfer("accessdenied.aspx");            }            else            {                Session["UID"] = UserID;                Server.Transfer("welcome.aspx");                            }                    }        }} 

View 7 Replies View Related

How To Check If Cursor Exists

Jan 27, 2008

Does anybody can tell me how to check if cursor exists ?
 I have a "try and catch" blocks.
I want to destroy the cursor when error occurred and it jumps into "catch" block.
Before I destroy the cursor I want to check if it exists, because the error could occurred before I have declared or opened the cursor.

View 3 Replies View Related

Check If Primary Key Exists

Mar 18, 2006

Hi!

I have created a formview which I among other things uses to insert new values into a database. What I want to check is if the primary key which is put into the form already exists in the db. If it is I want to get a message to my web page, if not the data can be inserted.

How can I do this?

And if the only way to control this is to create a stored procedure. How do I write such a proc?

View 1 Replies View Related

How To Check If A Liked Server Exists

Feb 25, 2004

Hi there,

I am quite new to SQL Server and am having a bit of trouble.

I have created a linked server with the datasource an excel spreadsheet.

I am trying to write a bit of T-SQL that basically checks if the linked server exists. If it does do X, if not do Y.

Can anyone help, its driving me bananas!

View 5 Replies View Related

Check If Cursor Exists

May 11, 2004

I declare a cusror named crInv inside a loop.
Since I open this cursor a lot of times I want to check if is already opened.
I try to use the Cursor_status function but it always returns -3.
The syntax is:

DECLARE crInv SCROL CURSOR FOR
SELECT Val1, Val2 FROM TABLE1 WHERE Val3=450

If Cursor_Status('local','crInv')>0 BEGIN
CLOSE crInv
DEALLOCATE crInv
END

This code is inside a loop.
If I PRINT Cursor_Status('local','crInv') before and after the DECLARE statement it always returns -3.
What is wrong??

Best regards,
Manolis

View 2 Replies View Related

Check If The Table Exists

May 20, 2008

Hi,

This my first time using the link server to read the files directly from within SQL2005, so issues the following link:-

EXEC sp_addlinkedserver
@server = N'MYVFPSERVER', -- Your linked server name here
@srvproduct=N'Visual FoxPro 9', -- can be anything
@provider=N'VFPOLEDB',
@datasrc=N'"C:PROGRAM FILESMICROSOFT VISUAL FOXPRO 9Samplesdata estdata.dbc"'

After that i can open query and do the import issues, but how can check if the table exists before issues the query.

Best regards

View 2 Replies View Related

Check If A View Exists

Jun 5, 2008

Hello all.

Can anyone tell me how to go about establishing if a particular view exists on a table?

Thanks.

View 2 Replies View Related

Check If Value Exists In Database?

Dec 9, 2006

Hi,

I'm wondering is there a command that I can use to check if a certain value exists in the database? Something that returns true or false perhaps?

SELECT * FROM Customers WHERE ID ='1'

Ok so that's simple, but how can I return a true or false if '1' is a value that exists in the db?

thanks.

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved