Search
 
SCRIPT & CODE EXAMPLE
 

SQL

if role exists sql

IF EXISTS (
    SELECT * 
    FROM sys.database_principals 
    WHERE name = 'role_a' 
        and type = 'R'
        )
BEGIN   -- Role_A exists, add to role
    ALTER ROLE [role_a] ADD MEMBER [Domain/SqlAgent]
END
ELSE IF EXISTS (
    SELECT * 
    FROM sys.database_principals 
    WHERE name = 'role_b' 
        and type = 'R'
        )
BEGIN   -- Role_B exists, add to role
    ALTER ROLE [role_b] ADD MEMBER [Domain/SqlAgent]
END
Comment

PREVIOUS NEXT
Code Example
Sql :: oracle boolean to varchar 
Sql :: calculer pourcentage mysql 
Sql :: subquery in mysql 
Sql :: how to replace null values in sql 
Sql :: top frequency in sql server 
Sql :: how to set all the time serveroutput on in oracle sql developer 
Sql :: order of sql 
Sql :: sql delete just one row 
Sql :: prisma transaction 
Sql :: mysql show column type 
Sql :: do block in postgresql 
Sql :: select query in mongodb 
Sql :: oracle undo usage per session 
Sql :: how to avoid duplicate records in sqlite 
Sql :: json_modify sql server 
Sql :: how to insert same table data using mysql query 
Sql :: cast as decimal postgresql 
Sql :: linq inner join 
Sql :: cross join sl 
Sql :: sql server epoch to datetime 
Sql :: how to reset the identity column in sql server 
Sql :: android sqlite get rows count 
Sql :: update statement postgres 
Sql :: sql server express 
Sql :: mysql delete if not in another table 
Sql :: drop constraint in ms sql 
Sql :: right join 
Sql :: python list from sql 
Sql :: execution time of mysql query 
Sql :: sql check if column exists 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =