June 2, 2006 at 7:43 am
Hi,
Declare @user varchar(200)
set @user = 'mymachine\vishal'
GRANT EXECUTE ON mytest_sp TO @user
GO
I am trying to run the above script it given me the following error:
Server: Msg 170, Level 15, State 1, Line 4
Line 4: Incorrect syntax near '@user'.
Please help....
June 2, 2006 at 9:18 am
this should do the trick
declare @exec varchar(500),
@user varchar(200)
set @user = 'mymachine\vishal'
select @exec = GRANT EXECUTE ON mytest_sp TO ' + @user
exec (@exec)
June 2, 2006 at 9:43 am
June 5, 2006 at 10:55 am
You also might want to search the forums here for 'dynamic sql'. There are lots of discussions on this here. This way you will have a better understanding.
RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply