declare my_cursor cursor scroll dynamic for select * from t_msg open my_cursor declare @name sysname fetch next from my_cursor into @name while(@@fetch_status=0) begin print 'UserName: ' + @name --fetch next from my_cursor fetch next from my_cursor i…