12

I currently have a website hosted developed with kentico 7. I tried importing the exported website into my localhost and that failed. In my findings, i realised that each table in the online version has a bvs (the database user created) prefix. I have tried creating the same scenario on my localhost without any luck. Does anyone have an idea ?

Here is the error displayed at importation.

enter image description here

Peter
  • 203
  • 2
  • 4
  • 13
  • 1
    what the error you are getting? create bvs user and schema on the localhost and then import. – Hiten004 Apr 22 '15 at 15:24
  • i did that already. I noticed I have the prefix dbo on all my tables in localhost and bvs on all tables in the online version. I have tried `EXEC sp_changedbowner 'bvs'` but it returned the error : `The proposed new database owner is already a user or aliased in the database.` – Peter Apr 22 '15 at 15:30
  • "I tried importing the exported website into my localhost and that failed" what failure did you get? – A ツ Apr 22 '15 at 15:42
  • See my update for the error page. – Peter Apr 23 '15 at 13:04

2 Answers2

18

You can change the schema owner using this command:

ALTER AUTHORIZATION ON SCHEMA::bvs TO db_owner;
Alex
  • 21,273
  • 10
  • 61
  • 73
12

Try this out:

USE MyDB
GO
ALTER AUTHORIZATION ON SCHEMA::bvs TO dbo;
GO 
SP_DROPUSER 'bvs'
GO
SP_CHANGEDBOWNER 'bvs'
FutbolFan
  • 13,235
  • 3
  • 23
  • 35
  • `The database principal owns a schema in the database, and cannot be dropped.` and `The proposed new database owner is already a user or aliased in the database.` respectively – Peter Apr 22 '15 at 15:36
  • I have. The result is what I posted in my comment. – Peter Apr 22 '15 at 15:46
  • @Rookie13 Could you also explain your answer? Such answers are always stronger. – Magnilex Apr 22 '15 at 17:10
  • Stronger? I am suggesting Peter to change the authorization for user 'bvs' to dbo. so he can have permissions to drop and change dbowner. – FutbolFan Apr 22 '15 at 17:40
  • @Rookie13, thanks for your responses so far. currently I have my tables with the prefix `dbo` while I want it as `bvs` (I'm trying to be as simple as possible). I believe if I can achieve that, my issues will be resolved. Any idea? – Peter Apr 23 '15 at 11:07
  • Check out this article and see if it provides any information that might be useful: http://www.mssqltips.com/sqlservertip/2620/steps-to-drop-an-orphan-sql-server-user-when-it-owns-a-schema-or-role/ – FutbolFan Apr 23 '15 at 17:37
  • 1
    WARNING: This will drop all existing permissions on objects in the schema. See https://dba.stackexchange.com/a/247459/176679. – lehiester Sep 10 '19 at 19:27