I am trying to execute Stored Procedure on a regular basis using a SQL Job and store the results of this into a .txt file in a folder location.
I have used the BCP command which is like:
DECLARE @command VARCHAR(1000)
SET @command = 'BCP "Exec [DatabaseName].[dbo].[StoredProcedureName] " queryout "D:\In\ErrorDetails'+ '.txt" -c -T -t -k'
EXEC xp_cmdshell @command
I need this to execute only if results of SP are not null.