tsql - Create User from a different DB in SQL Server -


is there way can create user on database master db(or other db)

if exists (select 1   j_test.sys.database_principals  name = n'test_user')    drop user j_test.[test_user]; --doesnt't work. 

you either need change context database or dynamically go there:

exec j_test..sp_executesql n'drop user test_user;'; 

Comments

Popular posts from this blog

Using 'OR' and 'AND' in SQL Server -

c++ - NetBeans Remote Development with additional configuration -

visual studio - TFS will not accept changes I've made to a Java project -