resolve:for create file :Create Proc UCreateTextFile(@Filename VarChar(100),@Text nText)AS DECLARE @FileSystem int DECLARE @FileHandle int DECLARE @RetCode int EXECUTE @RetCode = sp_OACreate 'Scripting.FileSystemObject' , @FileSystem OUTPUT IF (@@ERROR|@RetCode > 0 Or @FileSystem < 0) RAISERROR ('could not create FileSystemObject',16,1) EXECUTE @RetCode = sp_OAMethod @FileSystem , 'OpenTextFile' , @FileHandle OUTPUT , @Filename, 2, 1 IF (@@ERROR|@RetCode > 0 Or @FileHandle < 0) RAISERROR ('could not create File',16,1) EXECUTE @RetCode = sp_OAMethod @FileHandle , 'Write' , NULL , @text IF (@@ERROR|@RetCode > 0 ) RAISERROR ('could not write to File',16,1) EXECUTE @RetCode = sp_OAMethod @FileHandle , 'Close' IF (@@ERROR|@RetCode > 0) RAISERROR ('Could not close file ',16,1) EXEC sp_OADestroy @filehandle IF (@@ERROR|@RetCode > 0) RAISERROR ('Could not destroy file object',16,1) EXEC sp_OADestroy @FileSystemGofor read fileCREATE FUNCTION [dbo].[ufsReadfileAsString](@Path VARCHAR(255),@Filename VARCHAR(100))RETURNS Varchar(max)ASBEGINDECLARE @objFileSystem int ,@objTextStream int, @objErrorObject int, @strErrorMessage Varchar(1000), @Command varchar(1000), @Chunk Varchar(8000), @String varchar(max), @hr int, @YesOrNo intSelect @String=''select @strErrorMessage='opening the File System Object'EXECUTE @hr = sp_OACreate 'Scripting.FileSystemObject' , @objFileSystem OUTif @HR=0 Select @objErrorObject=@objFileSystem, @strErrorMessage='Opening file "'+@path+'\'+@filename+'"',@command=@path+'\'+@filenameif @HR=0 execute @hr = sp_OAMethod @objFileSystem , 'OpenTextFile' , @objTextStream OUT, @command,1,false,0--for reading, FormatASCIIWHILE @hr=0 BEGIN if @HR=0 Select @objErrorObject=@objTextStream, @strErrorMessage='finding out if there is more to read in "'+@filename+'"' if @HR=0 execute @hr = sp_OAGetProperty @objTextStream, 'AtEndOfStream', @YesOrNo OUTPUT IF @YesOrNo<>0 break if @HR=0 Select @objErrorObject=@objTextStream, @strErrorMessage='reading from the output file "'+@filename+'"' if @HR=0 execute @hr = sp_OAMethod @objTextStream, 'Read', @chunk OUTPUT,4000 SELECT @String=@string+@chunk endif @HR=0 Select @objErrorObject=@objTextStream, @strErrorMessage='closing the output file "'+@filename+'"'if @HR=0 execute @hr = sp_OAMethod @objTextStream, 'Close'if @hr<>0 begin Declare @Source varchar(255), @Description Varchar(255), @Helpfile Varchar(255), @HelpID int EXECUTE sp_OAGetErrorInfo @objErrorObject, @source output,@Description output,@Helpfile output,@HelpID output Select @strErrorMessage='Error whilst ' +coalesce(@strErrorMessage,'doing something') +', '+coalesce(@Description,'') select @String=@strErrorMessage endEXECUTE sp_OADestroy @objTextStream -- Fill the table variable with the rows for your result set SET @String = REPLACE(@String, ' Connected="True" ', 'Connected="False" ') RETURN @stringENDGO