How to determine if I have CREATE TABLE permission?

How can I programmatically determine if the current user has CREATE TABLE permissions in the current database?

I am writing a tool that will do lengthy processing and then create database tables to save the results. I want to create tables only if processing is complete. But if the user cannot create tables, then there is no time to process the time. I would like to detect a resolution problem and get the job done quickly.

This will be from a C # application, and I cannot assume that any special libraries will be installed that probably exclude SQL-DMO and SMO. If there is an easy way to check permissions with a T-SQL / script query, that would be ideal.

+5
source share
1 answer

Why not create a table first, and if that fails, don't go on?

However, you can also use the following function HAS_PERMS_BY_NAME:

SELECT HAS_PERMS_BY_NAME(db_name(), 'DATABASE', 'CREATE TABLE');

Further information here:

http://msdn.microsoft.com/en-us/library/ms189802.aspx

+9
source

All Articles