The database principal owns a schema in the database, and cannot be dropped. – Fix

If you try to drop a user that owns a schema, you will receive the following error message: [code] The database principal owns a schema in the database, and cannot be dropped. [/code] In order to drop the user, you need to find the schemas they are assigned, then transfer the ownership to another user or role [cc lang=”sql”] SELECT s.name FROM sys.schemas s WHERE s.principal_id = USER_ID(‘joe’) — now use the names you find from the above query below in place of the SchemaName below ALTER AUTHORIZATION ON SCHEMA::SchemaName TO dbo [/cc]

Continue reading ...

Insert Carriage Return Line Feed to String

Here is a clean and efficient way to embed carriage returns into a string. I prefer this way instead of concatenating the entire CHAR(13)+CHAR(10) to the end of every string. This replace function also comes in handy in most instances where you need to append strings. [cc lang=”sql”] declare @Note varchar (200) SET @Note = ‘Line One.[crlf];Line Two[crlf]Line Three.’ SET @Note = REPLACE(@Note,'[crlf]’,CHAR(13)+CHAR(10)) PRINT @Note [/cc] Output: [code] Line One. Line Two. Line Three. [/code]

Continue reading ...

Featured Articles

 Site Author

  • Thanks for visiting!
css.php