Error on query table for readonly user

Error on query table for readonly user

According this below like I caret readonly user but when I run query this error appears:

DENY INSERT, UPDATE, DELETE ON SCHEMA :: [dbo] TO <userName>;
REVOKE SELECT ON SCHEMA :: [dbo] FROM 
<userName>;
declare commands cursor for
SELECT 'GRANT SELECT ON [dbo].' + QUOTENAME(t.TABLE_NAME) + ' TO 
<userName>;'
FROM TableDetails t
WHERE t.TABLE_NAME NOT LIKE 'AaaAccHttpSession' AND t.TABLE_NAME NOT LIKE 'AaaPassword' AND t.TABLE_NAME NOT LIKE 'RememberMeDetails' AND t.TABLE_NAME NOT LIKE 'ADSTFAUserEnrollment' AND t.TABLE_NAME NOT LIKE 'CustomFunctionDetails' AND t.TABLE_NAME NOT LIKE 'AdminAuditHistoryJson' AND t.TABLE_NAME NOT LIKE 'MobileAuthKey' AND t.TABLE_NAME NOT LIKE 'COMMONPASSWORD' AND t.TABLE_NAME NOT LIKE 'PasswordInfo' AND t.TABLE_NAME NOT LIKE 'PasswordResetLink' AND t.TABLE_NAME NOT LIKE 'BackupSchedule' AND t.TABLE_NAME NOT LIKE 'DBCredentialsAudit' AND t.TABLE_NAME NOT LIKE 'ChatJson' AND t.TABLE_NAME NOT LIKE 'ThrottleExceedingHistory' AND t.TABLE_NAME NOT LIKE 'UserAdditionalFields_multiselect' AND t.TABLE_NAME NOT LIKE 'UserAdditionalFields_history' AND t.TABLE_NAME NOT LIKE 'UserAdditionalFields_historydiff' AND t.TABLE_NAME NOT LIKE 'CustomPickListValues' AND t.TABLE_NAME NOT LIKE 'CustomModuleInstance' AND t.TABLE_NAME NOT LIKE 'CustomModuleInstanceImages' AND t.TABLE_NAME NOT LIKE 'CustomModuleDescription' AND t.TABLE_NAME NOT LIKE 'CustomModuleHistory' AND t.TABLE_NAME NOT LIKE 'CustomModuleHistoryDiff' AND t.TABLE_NAME NOT LIKE 'CM_Tasks' AND t.TABLE_NAME NOT LIKE 'CM_Comments' AND t.TABLE_NAME NOT LIKE 'CM_Attachments' AND t.TABLE_NAME NOT LIKE 'Custom_001' AND t.TABLE_NAME NOT LIKE 'Custom_MultiSelect_001';

declare @cmd varchar(max)

open commands
fetch next from commands into @cmd
while @@FETCH_STATUS=0
begin
exec(@cmd)
fetch next from commands into @cmd
end

close commands
deallocate commands



Error
Msg 15151, Level 16, State 1, Line 1
Cannot find the object 'AdventNetErrorCode', because it does not exist or you do not have permission.
Msg 15151, Level 16, State 1, Line 1
Cannot find the object 'MySQLErrorCode', because it does not exist or you do not have permission.
Msg 15151, Level 16, State 1, Line 1
Cannot find the object 'OracleErrorCode', because it does not exist or you do not have permission.
Msg 15151, Level 16, State 1, Line 1
Cannot find the object 'MsSQLErrorCode', because it does not exist or you do not have permission.
Msg 15151, Level 16, State 1, Line 1
Cannot find the object 'PgSQLErrorCode', because it does not exist or you do not have permission.
Msg 15151, Level 16, State 1, Line 1
Cannot find the object 'ModuleStartStopProcessor', because it does not exist or you do not have permission.

                  New to ADSelfService Plus?