tsql - How to check if the USER is already created in the database or not in SQL? -
tsql - How to check if the USER is already created in the database or not in SQL? -
is there way can know if user(not login) created in database? mean user not login, since, know how check login. need check user created within specific db & role assigned it.
this code checking login:
select name sys.server_principals name = 'test_user'
but how user? since need create user , assign role if not created. otherwise, go on without creating.
thanks
how about:
use (your database want check user's existence in) select * sys.database_principals name = '(your user name check here)'
sys.server_principals
shows logins defined on server level - sys.database_principals
shows principals (e.g. user accounts) on database level.
sql tsql
Comments
Post a Comment