I posted this thread in security also. But cross posting here with hope of getting a quick answer.
I am trying to generate the create database script using SMO. The issue is the user account which connects to SQL server is not SA, SMO fails to generate the "Create Database" script with error User ZZZ\User1 does not have permission to run DBCC SHOWFILESTATS.
Is it possible to generate a "Create database" script using SMO when you are connecting to the SQL server using NON-ADMIN account
The user login is a part of db_Datareader role on the database. I tried following grant permission to the concerned account at server level
Grant view any database, grant view any definition and grant view server state. Still it fails.