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)
 Grant permissions on objects on other DB Servers.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 01/09/2006 :  08:28:57  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Dmytro writes "Have a problems with subject. Here is my stor proc.

--------------------------
CREATE PROCEDURE Encrypt.GrantsForEncrypt @GrantRevoke tinyint, @ServerName varchar(50), @DBName varchar(50), @TableName varchar(50), @UserId varchar(50) AS
declare @sqlGrant varchar(200)

set @sqlGrant1 = 'GRANT SELECT, UPDATE ON [' + @ServerName + '].' + @DBName + '.dbo.' + @TableName + ' TO [' + @UserId + ']'

if @GrantRevoke = 0
begin
exec (@sqlGrant)
end
----------------------------

When I'm trying to run this one as Encrypt user (he has db_securityadmin role in all databases), it says "The object name 'reports.db.foo.com.test.dbo.' contains more than the maximum number of prefixes. The maximum is 2." where reports.db.foo.com is name of the Database server.
Is there any solutions about this problem??? I need help ASAP.

PS I've tried to use OPENQUERY:
SELECT * FROM OPENQUERY(TEST,'SELECT ''x'' as Testme Use pubs GRANT SELECT ON dbo.authors TO Encrypt')
but it didn't help me. OpenQuery can see only first statement, so Grant statement doesn't take effect.

Thank you."

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 01/09/2006 :  09:05:22  Show Profile  Visit nr's Homepage  Reply with Quote
something like

declare @sqlGrant varchar(200)
set @sqlGrant1 = 'exec [' + @ServerName + '].' + @DBName + '.dbo.sp_executesql N''GRANT SELECT, UPDATE ON ' + @TableName + ' TO [' + @UserId + ']'' '
exec (@sqlGrant1)


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 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