Question : Error dropping shema

Attempting to drop shema then user via MSSQL 2005 Server Mngr but get the following error.
I do know this user account is not logged in when this error occurs.

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot drop schema 'EPIDIRECT\fmg.Jackie.Infusino' because it is being referenced by object 'ds_GetServerCase'.
(Microsoft SQL Server, Error: 3729)

Any suggestion how to determine dependency causing this problem and how to correct?

Answer : Error dropping shema

This query will generate script to change schema name for all the tables:

SELECT 'ALTER SCHEMA dbo TRANSFER ' + s.Name + '.' + p.Name FROM sys.Tables p INNER JOIN
sys.Schemas s on p.schema_id = s.schema_id WHERE s.Name = 'oldschemaname'

this second is 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 = 'oldschemaname'

First you will alter all these objects and after this delete the schema.
Random Solutions  
 
programming4us programming4us