SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 deny, grant problem
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

baran121
Starting Member

5 Posts

Posted - 12/04/2012 :  10:23:10  Show Profile
Hi everyone i wanna specially DENY, GRANT tables for some user
there is a code which i tried to run.
there is a mistake
Line 14: Incorrect syntax near '@name'.

please help me. thank you


declare @name varchar(30)

DECLARE c1 CURSOR FOR
Select name From sysobjects WHERE xtype in ('U','P','FN','V') order by name

OPEN c1
FETCH NEXT FROM c1 INTO @name
WHILE @@FETCH_STATUS=0
BEGIN

GRANT SELECT, INSERT, DELETE ON @name TO ARGEMAS

FETCH NEXT FROM c1 INTO @name
END
CLOSE c1
DEALLOCATE c1

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 12/04/2012 :  10:56:24  Show Profile
Declare a variable up top like this:
DECLARE @sql NVARCHAR(4000);
Then change the code between begin and end to this:
BEGIN
    SET @sql = 'GRANT SELECT, INSERT, DELETE ON ' + @name + ' TO ARGEMAS'
    EXEC (@sql);
    
    FETCH NEXT FROM c1 INTO @name
END
Go to Top of Page

robvolk
Most Valuable Yak

USA
15688 Posts

Posted - 12/04/2012 :  10:58:19  Show Profile  Visit robvolk's Homepage
Please do not cross post: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=181176

Continue in the other thread.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000