Monday, November 1, 2010

Correct schema in a sql server database

Recently we came across the condition where there were multiple schema’s for the same object. Hope someone finds this useful.

This was solved using by running the result set of this query.

Script

Select 'Alter Schema dbo Transfer ' + [s].name+'.'+o.name  from sys.schemas s inner join sys.objects o on s.schema_id = o.schema_id and s.name = 'Test_user'
So what does this do? 
This simply transfers each object’s schema to dbo.

No comments:

Post a Comment