|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Wednesday, April 04, 2012 9:49 AM
Points: 44,
Visits: 42
|
|
Everyone is down on Cusors and then they turn right around and use sysobjects in their scripts.  Why not use the views Microsoft provided? SELECT specific_name FROM information_schema.routines where NOT specific_name like ('dt_%') I mean if you are going to do it the proper way, then do it all by the book. 
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, July 30, 2012 1:23 PM
Points: 290,
Visits: 44
|
|
We had a situation a while back in which a cursor based solution was faster than a t-sql solution. Note that this was NOT what we were attempting to prove to the developer! Oh well.
John Scarborough MCDBA, MCSA
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, June 05, 2013 9:12 PM
Points: 1,034,
Visits: 2,611
|
|
Cursors are like toilet plungers: you hope you don't have to use them, but it's nice to know how just in case. 
Tim Mitchell SQL Server MVP www.TimMitchell.net @Tim_Mitchell
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Sunday, September 18, 2011 6:11 PM
Points: 355,
Visits: 299
|
|
I looked up the bol. What min(name) here do ? SELECT @procname = min(name) FROM sysobjects WHERE xtype='P' and name > @procname and name not like 'dt_%'
Thanks.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, November 13, 2012 3:59 AM
Points: 210,
Visits: 108
|
|
If you wanted to avoid usiing extended stored prcedures you could do it like this. It's a bit more understandable than multiple nested select statements that are required for xp_execresultset to work properly... -- Specify the user account which should be DECLARE @login VARCHAR(50) SET @login = 'my_user_id'
DECLARE @sql VARCHAR(max)
Select @sql = Coalesce(@sql, '') + 'GRANT EXEC ON [' + [name] + '] TO [' + @login + ']' + Char(13) FROM sysobjects WHERE xtype = 'P' AND [name] NOT LIKE 'dt_%' EXEC (@sql) 
|
|
|
|
|
Say Hey Kid
      
Group: General Forum Members
Last Login: Monday, May 20, 2013 12:44 AM
Points: 666,
Visits: 58
|
|
To grant execute permissions to a user for all stored procs in a schema. Using the GUI Right click a stored proc. Click properties Click view schema permissions Add Object type -> user -> ok Brows Choose user -> ok Click on the user Under grant check execute.
|
|
|
|