Permission on Database I have a login user called TestUser created at the server level that is assigned to a read only role, now I need to create a user for the TestUser login on MyDb

USE [MyDB]
GO
CREATE USER [Test] FOR LOGIN [TestUser]
GO
GRANT SELECT TO [Test]
GO
DENY DELETE TO [Test]
GO
DENY INSERT TO [Test]
GO
DENY UPDATE TO [Test]
GO


everything is good but when I script that Test user created, I don't see in any place the script that I'm giving select and denying insert, delete and update
Most probably because you are using the generate scripts method to do so.

I would suggest to use open source DBA tools to view the permission or export.

Aliases : Export-SqlUser

Synopsis

Exports users creation and its permissions to a T-SQL file or host.

Description

Exports users creation and its permissions to a T-SQL file or host. Export includes user, create and add to role(s), database level permissions, object level permissions.

Example:


  PS C:> Export-DbaUser -SqlInstance sqlserver2014a -User User1, User2
  -Path C:\temp\users.sql


Exports ONLY users User1 and User2 from sqlserver2014a to the file C:\temp\users.sql