May 19, 2010 at 5:07 pm
Hi,
My requirement is to get the following output using the TSQL Script :
EXEC databasename.. sp_addrolemember 'db_datareader','username'
Following code i am trying to use :
declare @sqltext varchar(100)
set @sqltext = 'EXEC sp_addrolemember ''db_datareader'','username'''
--- Please modify above line to get the code as per my requirement
print @sqltext
May 19, 2010 at 5:33 pm
You can use this as a base
select 'EXEC sp_addrolemember ' +char(39) + db_name() + char(39)
+ ', ' + char(39) + name + char(39) from sys.sysusers
where uid > 4 and uid < 16384
Leo
Striving to provide a better service.
Leo
Nothing in life is ever so complicated that with a little work it can't be made more complicated.
May 19, 2010 at 5:37 pm
Leo.Miller (5/19/2010)
You can use this as a baseselect 'EXEC sp_addrolemember ' +char(39) + db_name() + char(39)
+ ', ' + char(39) + name + char(39) from sys.sysusers
where uid > 4 and uid < 16384
Leo
Striving to provide a better service.
Sory, I got distractred there it should be:
select 'EXEC sp_addrolemember ' +char(39) + 'db_datareader' + char(39)
+ ', ' + char(39) + name + char(39) from sys.sysusers
where uid > 4 and uid < 16384
Leo
Leo
Nothing in life is ever so complicated that with a little work it can't be made more complicated.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply