Search

Thursday, July 28, 2011

Change schema on tables and stored procedures in sql 2005

--Change schema for stored procedures

SELECT 'ALTER SCHEMA dbo TRANSFER '+'[' + s.Name + '].' + p.Name
FROM sys.Procedures p INNER JOIN
sys.Schemas s on p.schema_id = s.schema_id WHERE
s.Name <> 'dbo'

--Alter schemas on tables

SELECT 'ALTER SCHEMA dbo TRANSFER
' + TABLE_SCHEMA + '.' + TABLE_NAME FROM
INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo'

No comments:

Post a Comment