Check if role exists in DB?
try:
IF DATABASE_PRINCIPAL_ID('role') IS NULL
BEGIN
-- add user here
CREATE ROLE role AUTHORIZATION MyUser;
END
IF EXISTS
(
SELECT 1
FROM sys.database_principals
WHERE type_desc = 'DATABASE_ROLE'
AND name = 'name'
)
BEGIN
-- add user;
END