SQL server level permissions
I have not personally tried this, but have a look the the Idera Permission Extractor:

Free Tool SQL Permissions Extractor

If you need a sql solution, there is nothing built in. However, you can query the sys.server_permissions and sys.database_permissions tables. They contain the information needed to build the grant statements yourself. sys.server_role_members and sys.database_role_members contain the information needed to generate role membership scripts.