Is there a better approach than trying to write and just catching the exception?
We have various versions of the same database and today I’m working against a readonly version, this is fine for 99% of my tasks but the application sometimes saves its state back to the DB and I’d like to be able to try this iff the underlying SQL Server instance is writable.
Run a query against the server checking what permissions your user login has for that database. There is a built-in Transact-SQL function to do this named
HAS_PERMS_BY_NAME(Link to MSDN).Example query to check if you have
INSERTpermissions.Also have a look at
FN_BUILTIN_PERMISSIONS(Link to MSDN). This MSDN page has listings of the possible values that you can use inHAS_PERMS_BY_NAME.HTH,