Sure,
The stored procedures are all listed in the sysobjects table in the database 
( type='P'), all you need to do is loop through them and call the statement 
you supplied with the name of the stored proc. This should work, all though 
you could also use a cursor.

CREATE TABLE #SPs(
ID int identity,
SPName nvarchar(100))
INSERT INTO #SPs(SPName)
SELECT [Name] from Sysobjects where type='P'

DECLARE @i int
DECLARE @iMax int
DECLARE @changetext nvarchar(300)
SELECT @iMax = Count(*) FROM #SPs
SET @i = 1
while(@i <= @iMax)
BEGIN
SELECT @changetext = 'EXEC sp_changeobjectowner ''' + SPName + ''', ''dbo'''
FROM #SPs
WHERE ID = @i
EXEC(@changetext)
SET @i = @i + 1
END

DROP Table #SPs

On 9/12/05, sas0riza <[EMAIL PROTECTED]> wrote:
> 
> Hi,
> 
> Is is possible to change database object owners in a batch? For
> instance, I want to change the owner of my SPs to 'dbo', instead of
> one by one
> 
> EXEC sp_changeobjectowner 'whatever_SP', 'dbo'
> 
> Any help is greatly appreciated.
> 
> Thanks.
> 
> 
> 
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
> 


-- 
Dean Fiala
Very Practical Software, Inc
http://www.vpsw.com


[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to