SQL Statment, Pull Object name from database and Revoke

  • 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

  • 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!

  • Fixed my second issue as well by using another variable and execution statment!

    Thanks! ... I guess

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply