Cannot add rows to sysdepends for the current stored procedure

Hi experts,

Is anyone knows what the probolm of this scripts ? It won't executing because "Cannot add rows to sysdepends for the current stored procedure because it depends on the missing object 'usp_copy'. The stored procedure will still be created."
Please advice. thanks.

/***Copy files***/
USE MASTER
IF OBJECT_ID ('dbo.usp_copy') IS NOT NULL
DROP PROC dbo.usp_copy
GO

CREATE PROCEDURE USP_COPY AS

DECLARE @cmd VARCHAR(5000)
SET @cmd = 'mkdir c:\data\WeeklyData_'+ REPLACE(CONVERT(varchar(11),GETDATE(),100),' ','')
exec master..xp_cmdshell @cmd
set @cmd = 'copy c:\data\FTP_DOWNLOAD\*.zip c:\data\WeeklyData_'+ REPLACE(CONVERT(varchar(11),GETDATE(),100),' ','')
exec master..xp_cmdshell @cmd
set @cmd = 'copy c:\data\FTP_DOWNLOAD\*.Z c:\data\WeeklyData_'+ REPLACE(CONVERT(varchar(11),GETDATE(),100),' ','')
exec master..xp_cmdshell @cmd

EXEC usp_copy
GO
LIULIHUAAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
the procedure you create contains the call to run itself at the end, which is NOT what you want to do:

/***Copy files***/
USE MASTER
IF OBJECT_ID ('dbo.usp_copy') IS NOT NULL
DROP PROC dbo.usp_copy
GO

CREATE PROCEDURE USP_COPY AS

DECLARE @cmd VARCHAR(5000)
SET @cmd = 'mkdir c:\data\WeeklyData_'+ REPLACE(CONVERT(varchar(11),GETDATE(),100),' ','')
exec master..xp_cmdshell @cmd
set @cmd = 'copy c:\data\FTP_DOWNLOAD\*.zip c:\data\WeeklyData_'+ REPLACE(CONVERT(varchar(11),GETDATE(),100),' ','')
exec master..xp_cmdshell @cmd
set @cmd = 'copy c:\data\FTP_DOWNLOAD\*.Z c:\data\WeeklyData_'+ REPLACE(CONVERT(varchar(11),GETDATE(),100),' ','')
exec master..xp_cmdshell @cmd

GO

-- call the procedure outside the procedure:
EXEC USP_COPY
0
 
LIULIHUAAuthor Commented:
Thank you angelIII,

When I call the precedure outside the procedure works, the folder is created and all the files are copied, EXCEPTE it goes loop, the procedure goes nonstop.....
0
 
LIULIHUAAuthor Commented:
Hi,

The problem has been solved, just sapareated each of the command line as a singal sp. thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.