This batch job changes the object owner where the uid = UseNAme:
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
SELECT * from sysobjects where uid = user_id('UseNAme') declare @Return int exec @Return = sp_configure 'allow updates', '1' SELECT @Return as 'Returned Code' GO reconfigure WITH OVERRIDE GO DECLARE @Rows int, @Error int BEGIN TRANSACTION update sysobjects set uid = user_id('dbo') where uid = user_id('UseNAme') SELECT @Error = @@Error, @Rows = @@RowCount SELECT @Rows as '#Rows' IF @Rows > 0 BEGIN SELECT @Rows AS '#Rows' COMMIT TRANSACTION END else BEGIN SELECT @Error AS 'Error #' ROLLBACK TRANSACTION END exec sp_configure 'allow updates', '0' reconfigure WITH OVERRIDE go
For More Information
- What do you think about this tip? E-mail us at editor@searchDatabase.com with your feedback.
- The Best Microsoft SQL Server Web Links: tips, tutorials, scripts, and more.
- The Best SQL Web Links
- Have a SQL Server tip to offer your fellow DBA's and developers? The best tips submitted will receive a cool prize--submit your tip today!
- Ask your technical SQL Server questions--or help out your peers by answering them--in our live discussion forums.
- Ask the Experts yourself: Our SQL Server gurus are waiting to answer your toughest questions.