Error running SQL backup in a task - VisualCron - Forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


Kirklees
14 years ago
Hi,

I'm calling some SQL to run backups of our databases in a task and i'm getting the following error in the OUTPUT (stderr)
Quote:

Exception in Task: An SqlParameter with ParameterName '@RETURN_VALUE' is not contained by this SqlParameterCollection.



I have run the SQL successfully in Management Studio.

Can anyone help?

My SQL CODE is below - Thanks in advance.

DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name
DECLARE @BackupSetName VARCHAR(256) -- used for the verify

SET @path = 'H:\SQL Backups\User\'

SELECT @fileDate = replace((replace(convert(varchar(20), getdate(),113), ' ', '_')),':','_')

DECLARE db_cursor CURSOR FOR
SELECT name
FROM master.dbo.sysdatabases
WHERE name NOT IN ('master','model','msdb','tempdb')

OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name

WHILE @@FETCH_STATUS = 0
BEGIN

	SET @fileName = @path + @name + '_' + @fileDate + '.BAK'
    SET @BackupSetName = @name + @fileDate
    --BACKUP DATABASE @name TO DISK = @fileName
    BACKUP DATABASE @name TO  DISK = @fileName WITH NOFORMAT, NOINIT, NAME = @BackupSetName, SKIP, REWIND, NOUNLOAD,  STATS = 10
		declare @backupSetId as int
		select @backupSetId = position from msdb..backupset where database_name = @name and backup_set_id=(select max(backup_set_id) from msdb..backupset where  )
		if @backupSetId is null begin raiserror(N'Verify failed. Backup information for database ''DATABASENAME'' not found.', 16, 1)
		end
			RESTORE VERIFYONLY FROM  DISK = @fileName WITH  FILE = @backupSetId,  NOUNLOAD,  NOREWIND
	FETCH NEXT FROM db_cursor INTO @name
END

CLOSE db_cursor
DEALLOCATE db_cursor
Sponsor
Forum information
Support
14 years ago
Make sure that you use the MSSQL Direct connection type.

Also, try creating a new Task. Sounds like it is using the Job type instead of Text type of SQL.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
bocit
14 years ago
I am having the same problem.
I am using a connection type of "connecting to an SQL Server instance" and an SQL text type.
The error I am getting is "sqlparameter with parametername '@return_value' is not contained by this sqlparametercollection"

Any guesses ?
Support
14 years ago
Please try the same as I described in last post. Create a new Task and run it. Also, "connecting to an SQL Server instance" is no connection type. Edit the Connection and check that it is "MSSQL Direct".

bocit wrote:

I am having the same problem.
I am using a connection type of "connecting to an SQL Server instance" and an SQL text type.
The error I am getting is "sqlparameter with parametername '@return_value' is not contained by this sqlparametercollection"

Any guesses ?



Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
bocit
14 years ago
I don't have an option MSSQL direct.
The options I have are :
Standard Security,Standard Security alternative syntax, Trusted Connection, Trusted Connection alternative syntax, Connecting to an SQL Server Instance, Trusted connection from a CE device, connect via an IP address, Specyfing packet size.

Version of visualcron : 5.6.9
Build of visualcron : 17920

Thank you in advance
Support
14 years ago
That is the first thing you select when creating a new Connection. Try creating a new one and you will see.

bocit wrote:

I don't have an option MSSQL direct.
The options I have are :
Standard Security,Standard Security alternative syntax, Trusted Connection, Trusted Connection alternative syntax, Connecting to an SQL Server Instance, Trusted connection from a CE device, connect via an IP address, Specyfing packet size.

Version of visualcron : 5.6.9
Build of visualcron : 17920

Thank you in advance



Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top