Help with building a cursor string

  • Hi,

    I'm attempting to build a cursor in a stored procedure. HOwever when I execute

    the string it returns an error

    Server: Msg 207, Level 16, State 3, Line 1

    Invalid column name 'database'.

    declare @sqlstr_restoredatabaseList as nvarchar(500)

    The tsql I am using is

    declare @dbname as varchar (50)

    declare @dbname = 'database'

    set @sqlstr_restoredatabaseList = 'DECLARE RestoredatabaseList CURSOR FOR select SFmaintenanceHistoryID, maintenanceID, database_name, bak_date,shipped_location,bak_filename from ' + @tempHistoryTable + ' where latest_full = 1 and database_name = "' + @dbname + '"'

    Thanks

  • Problem solved thanks

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply