Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Statment, Pull Object name from database and Revoke


SQL Statment, Pull Object name from database and Revoke

Author
Message
falcon59x
falcon59x
Grasshopper
Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)

Group: General Forum Members
Points: 18 Visits: 33
Hey,

I am kind of new to SQL. I have lots of experience with Selects and Inserts and all that jazz, but this is the first time I have had to push beyond that. I am trying to Revoke all public rights to a database in SQL. I keep encountering two errors my revoke statement

REVOKE SELECT ON @ObjectName To public

wont take unless I put an object name in place of my variable.


The second error is comes from trying to pull an object out of a temporary database the SELECT statement is working but it keeps telling me it cant convert the Object from an NVARCHAR to an int. I understand this which is why I declared my variable as an NVARCHAR in the first place so why is it trying to convert into an int? Here is some example code

DECLARE @ObjectName NvarChar(30)

SELECT @ObjectName = (SELECT Rand(Object) FROM TempTable)

If anyone can tell me what is going on I would be much obliged!

Thanks
falcon59x
falcon59x
Grasshopper
Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)

Group: General Forum Members
Points: 18 Visits: 33
Hey,

I am updating my post I figured out the first problem, I cant use Rand() in that context I assume. Because when I re-wrote it without it worked!
falcon59x
falcon59x
Grasshopper
Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)

Group: General Forum Members
Points: 18 Visits: 33
Fixed my second issue as well by using another variable and execution statment!

Thanks! ... I guess
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search