use master
go
IF OBJECTPROPERTY(OBJECT_ID('dbo.sp_fileop'), 'IsProcedure') = 1
BEGIN
DROP PROCEDURE dbo.sp_fileop
IF OBJECTPROPERTY(OBJECT_ID('dbo.sp_fileop'), 'IsProcedure') = 1
PRINT '<<< FAILED DROPPING PROCEDURE dbo.sp_fileop >>>'
ELSE
PRINT '<<< DROPPED PROCEDURE dbo.sp_fileop >>>'
END
go
CREATE PROCEDURE sp_fileop;1 (
@filename varchar(255),
@line nvarchar(4000) = NULL
)
-- WITH ENCRYPTION
AS
/********************************************************************************/
/* Created By : Umachandar Jayachandran (UC) */
/* Created On : 07 November 1999 */
/* Description: These stored procedures provide wrappers for creating */
/* files, inserting lines & deleting the files. Simple one.*/
/* Can be improved by using OLE automation. */
/********************************************************************************/
/* Resources : https://umachandar.com/resources.htm */
/********************************************************************************/
DECLARE @cmdstr nvarchar(4000)
SELECT @cmdstr = 'echo ' + COALESCE(@line, '.') + '>' + @filename
EXEC master..xp_cmdshell @cmdstr, no_output
go
CREATE PROCEDURE sp_fileop;2 (
@filename varchar(255),
@line nvarchar(4000) = NULL
)
-- WITH ENCRYPTION
AS
DECLARE @cmdstr nvarchar(4000)
SELECT @cmdstr = 'echo ' + COALESCE(@line, '.') + '>>' + @filename
EXEC master..xp_cmdshell @cmdstr, no_output
go
CREATE PROCEDURE sp_fileop;3 (
@filename varchar(255)
)
-- WITH ENCRYPTION
AS
DECLARE @cmdstr nvarchar(4000)
SELECT @cmdstr = 'DEL ' + @filename
EXEC master..xp_cmdshell @cmdstr, no_output
GO
IF OBJECTPROPERTY(OBJECT_ID('dbo.sp_fileop'), 'IsProcedure') = 1
BEGIN
GRANT EXECUTE ON dbo.sp_fileop To Public
PRINT '<<< CREATED PROCEDURE dbo.sp_fileop >>>'
END
ELSE
PRINT '<<< FAILED CREATING PROCEDURE dbo.sp_fileop >>>'
go
This page was last updated on May 01, 2006 04:28 PM.