Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSget_file_existence

  No additional text.


Syntax

-- Name: sp_MSget_file_existence

-- Descriptions:

-- Parameters: as defined in create statement

-- Returns: 0 - success
--          1 - Otherwise

-- Security:
-- Requires Certificate signature for catalog access

create procedure sys.sp_MSget_file_existence (
@filename nvarchar(260),
@exists bit = 0 output
)
AS
    SET NOCOUNT ON

    DECLARE @command nvarchar(512)
    DECLARE @retcode int
    declare @echo_text nvarchar(20)

    select @echo_text = 'file_exists'

    /*
    ** The return code from xp_cmdshell is not a reliable way to check whether the file exists or
    ** not. It is always 0 on Win95 as long as xp_cmdshell succeeds.
    */

    select @command = N'if exist "' + sys.fn_escapecmdshellsymbolsremovequotes(@filename) collate database_default + N'" echo ' + @echo_text

    create table #text_ret(cmdoutput nvarchar(255) collate database_default null)

    insert into #text_ret exec @retcode = master.dbo.xp_cmdshell @command
    if @@error <> 0 or @retcode <> 0
        return 1

    if exists (select * from #text_ret where ltrim(rtrim(cmdoutput)) = @echo_text)
        select @exists = 1
    else
        select @exists = 0

    drop table #text_ret

 
Last revision 2008RTM
See also

  sp_adddistributiondb (Procedure)
sp_attachsubscription (Procedure)
sp_copysubscription (Procedure)
sp_MScopysnapshot (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash