My problem is the following:
I have some aliased users and want to delete them and create them again as normal users, not as aliased. Then I have to assign them to the same db's they were assigned to, and make them members of a specified group.
Here's the code:
CREATE PROCEDURE sp_delaliases AS
set nocount on
declare @sid varbinary(85),
@loginname sysname,
@defdb sysname
create table #da
(
Name sysname Null,
sid varbinary(85) Null,
DefaultDBName sysname Null
)
insert into #da select name,sid,db_name() from sysusers where isaliased=1
select * from #da
--This is the list of all aliases and the db's they are assigned to.
Now how to go further?
May I need some code from the sp_adduser and/or from any other sp's?
Or can I simply put the names into variables, and execute the sp_adduser for them? If yes then how? (I haven't got enough experience in this)