Today I faced the below issue while transfering objects from one schema to other schema
Msg 15348, Level 16, State 1, Line 1 Cannot transfer a schemabound object.
First we will see how to transfer objects from one schema to other schema
ALTER SCHEMA <NewSchemaName> TRANSFER SchemaName.ObjectName
To create query to transfer all objects including tables, functions, stored procedures and views, Use the below query
SELECT 'ALTER SCHEMA <NewSchemaName> TRANSFER OldSchemaName.'+name
WHERE type IN ('U','V','P','Fn')
AND SCHEMA_NAME(SCHEMA_ID) = 'OldSchemaName'
Copy the result from the grid and execute on the desired database, all the objects will get transfered to new schema. You may encounter error if there are any objects with schema binding then you need to remove the schema binding and then transfre the objects
How to know which are schema binding objects
SELECT Schema_name(so.schema_id) AS [schema], Object_name(sd.id) AS objectname,
so.type_desc AS objecttype
FROM sys.sysdepends sd INNER JOIN sys.columns sc ON sd.depid = sc.object_id
AND sd.depnumber = sc.column_id INNER JOIN sys.objects so ON sd.id = so.object_id
WHERE sd.deptype = 1
GROUP BY so.schema_id, sd.id, so.type_desc
Pull the views which has schema binding dependency and drop those views and transfer the objects to new schema and re-create the views with schema binding again.