Home Forums SQL Server 7,2000 T-SQL variable tablename in cursor select stmt RE: variable tablename in cursor select stmt

  • Change the cursor2 declare to this

    declare @sql nvarchar(4000)
    
    set @sql = '
    DECLARE cursor2 CURSOR
    GLOBAL
    DYNAMIC
    FOR
    SELECT sum(file_size_bytes) , Lseries from ' + @filename + ' group by Lseries
    FOR READ ONLY
    '
    exec(@sql)

    Far away is close at hand in the images of elsewhere.
    Anon.