I need to run this SQL from a OSQL command.
DECLARE @dt varchar(100), @cmdd1 varchar(1000), @cmdd2 varchar(1000), @cmd varchar(1000)
SELECT @dt=(convert(char(20),DATEPART(dd,getdate())))
EXEC master..xp_cmdshell 'cd\'
SET @cmdd1 = 'DEL C:\script\Archive\'+@dt+'*.prn'
PRINT @cmdd1
EXEC master..xp_cmdshell @cmdd1
This query is saved as delete.qry
My batch file reads:
osql -U sa /P /i c:\script\delete.qry
Now when I run the batch file it tries to delete a file C:\script\Archive\9 in the given directory
and then for the *.prn tries to find the file in C:\winnt\system32.
Why is this happenning? Any suggestions?
Basically I am tring to delete the file that would have the current days date. All myu files have name like
7thICD9CodeFile
8thICD9CodeFile
9thICD9CodeFile
etc
Thanks for all ur help in advance
DECLARE @dt varchar(100), @cmdd1 varchar(1000), @cmdd2 varchar(1000), @cmd varchar(1000)
SELECT @dt=(convert(char(20),DATEPART(dd,getdate())))
EXEC master..xp_cmdshell 'cd\'
SET @cmdd1 = 'DEL C:\script\Archive\'+@dt+'*.prn'
PRINT @cmdd1
EXEC master..xp_cmdshell @cmdd1
This query is saved as delete.qry
My batch file reads:
osql -U sa /P /i c:\script\delete.qry
Now when I run the batch file it tries to delete a file C:\script\Archive\9 in the given directory
and then for the *.prn tries to find the file in C:\winnt\system32.
Why is this happenning? Any suggestions?
Basically I am tring to delete the file that would have the current days date. All myu files have name like
7thICD9CodeFile
8thICD9CodeFile
9thICD9CodeFile
etc
Thanks for all ur help in advance