Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Truncate Expand / Collapse
Author
Message
Posted Wednesday, August 18, 2010 7:12 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, May 31, 2013 11:47 AM
Points: 128, Visits: 224
I have a stored procedure that has several functions in it.

Two of them are:
Truncate a table
Insert to that same table.

I truncate (rather than) because I thought that was the best way to get the index (seed) back to the number 1.
I need to assign a DataBase Role the ability to truncate to they may execute this Store Procedure.

Execute As Self looks like it may work BUT, I can't seem to get it working in 2000 (MSSQL 7).

If I can't use Execute As Self, maybe I just am not using correctly, which other permission is the best to grant.

I would really appreciate your help,
Post #971107
Posted Wednesday, August 18, 2010 8:18 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 4:56 PM
Points: 31,168, Visits: 15,612
Is this SQL 2000? I don't believe EXECUTE AS works in 2000.

AFAIK, in 2000 you had to be the owner of the table for truncate.

http://msdn.microsoft.com/en-us/library/aa260621%28SQL.80%29.aspx







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #971165
Posted Wednesday, August 18, 2010 11:11 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:09 PM
Points: 40,172, Visits: 36,560
iirc, to truncate a table you have to be either
1) Owner of the table
2) member of ddl_admin fixed database role.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #971318
Posted Wednesday, August 18, 2010 11:15 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, May 31, 2013 11:47 AM
Points: 128, Visits: 224
I've added ddl_admin to the people that need to execute this Stored Procedure.

It has worked in testing.

I'll know for sure next week when it's deployed, but it looks good. When we upgrage, then perhaps I can change the Procedure to Execute As. That might be better.
Post #971321
Posted Wednesday, August 18, 2010 11:26 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:09 PM
Points: 40,172, Visits: 36,560
Ken@Work (8/18/2010)
I've added ddl_admin to the people that need to execute this Stored Procedure.


Just bear in mind that ddl_admin gives them the permission to create, alter and drop any table, view, procedure, function, etc in the database.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #971327
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse