Tom Moreau
3/23/2007 12:34:00 PM
Try either one of the following:
-- 1
select 'EXEC sp_addrolemember SSE_ROLE,' + LOGIN
from S_USER
-- 2
select 'sp_addrolemember SSE_ROLE,' + LOGIN + CHAR (13) + CHAR (10) + 'GO' +
CHAR (13) + CHAR (10)
from S_USER
--
Tom
----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS
SQL Server MVP
Toronto, ON Canada
.
"Mukut" <hidevraj@gmail.com> wrote in message
news:1174652075.165663.57080@n59g2000hsh.googlegroups.com...
Hi All,
We have a table called S_USER which is having a column named
LOGIN.This table contain Logins for more than 1000 users.
Now, after creating LOGINs & USERs we need to give SSE_ROLE to those
LOGINs. We wrote the below query for generating the sql for all those
logins(so that we can execute it by copy & past it in query analyzer).
select 'sp_addrolemember SSE_ROLE,' + LOGIN
from S_USER
OUTPUT:
sp_addrolemember SSE_ROLE,ARTISIEA
sp_addrolemember SSE_ROLE,AWADE
sp_addrolemember SSE_ROLE,BALBEURS
sp_addrolemember SSE_ROLE,BALTHAZC
------------------------------------
------------------------------------
after copy this resultset & paste it in query analyzer, when we ran it
we got the below error:
Incorrect syntax near 'sp_addrolemember'.
We found that 'Go' is missing between two lines.
Would you please help us to write a query so that output will be like
this:
sp_addrolemember SSE_ROLE,ARTISIEA
go
sp_addrolemember SSE_ROLE,AWADE
go
sp_addrolemember SSE_ROLE,BALBEURS
go
sp_addrolemember SSE_ROLE,BALTHAZC
go
Apology for any mistake or inconvenience in understanding the above
issue.
Thanks,
Mukut