Showing posts with label dropped. Show all posts
Showing posts with label dropped. Show all posts

Saturday, February 25, 2012

Accidentally dropped these tables

I dropped these tables MSreplication_subscriptions and MSsubscription_agents
used for replication on the subscribing end.
How can I recreate them since its a system table.
From sp_MScreate_sub_tables
CREATE TABLE dbo.MSreplication_subscriptions
(
publisher sysname NOT NULL,
publisher_db sysname NOT NULL,
publication sysname NULL,
independent_agent bit NOT NULL,
subscription_type int NOT NULL,
distribution_agent sysname NULL,
time smalldatetime NOT NULL,
description nvarchar(255) NULL,
transaction_timestamp varbinary(16) NOT NULL,
-- SyncTran
update_mode tinyint NOT NULL,
agent_id binary(16) NULL,
subscription_guid binary(16) NULL,
subid binary(16) NULL,
immediate_sync bit NOT NULL default 1 -- sync_mode with a default of 1
)
CREATE TABLE dbo.MSsubscription_agents
(
id int identity,
publisher sysname NOT NULL,
publisher_db sysname NOT NULL,
publication sysname NOT NULL,
subscription_type int NOT NULL,
queue_id sysname NULL,
update_mode tinyint default 0 not null, -- 0 = read only, 1 =
sync/immediate, 2 = queued, 3 = failover, 4 = sqlqueued, 5 = sqlqueued
failover
failover_mode bit default 0 not null, -- 0 - sync/immediate, 1 = queued
spid int NOT NULL,
login_time datetime NOT NULL,
allow_subscription_copy bit default 0 not null,
attach_state int default 0 not null, -- 0: not attached 1 attached but
not processed 2 attached and processed.
attach_version binary(16) default newid() not null,
last_sync_status int NULL, -- allow null for upgrade
last_sync_summary sysname NULL, -- allow null for upgrade
last_sync_time datetime NULL, -- allow null for upgrade
queue_server sysname NULL -- only used for MSMQ based updating
subscribers
)
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:%23TZtfkaXFHA.3712@.TK2MSFTNGP09.phx.gbl...
> I dropped these tables MSreplication_subscriptions and
MSsubscription_agents
> used for replication on the subscribing end.
> How can I recreate them since its a system table.
>
|||But I guess just creating those tables may not be enough.. Am i right ? I
know it has some data in there .. Will the agents still fail ?
"Hilary Cotter" <hilary.cotter@.gmail.com> wrote in message
news:O6Qwki6XFHA.2124@.TK2MSFTNGP14.phx.gbl...
> From sp_MScreate_sub_tables
> CREATE TABLE dbo.MSreplication_subscriptions
> (
> publisher sysname NOT NULL,
> publisher_db sysname NOT NULL,
> publication sysname NULL,
> independent_agent bit NOT NULL,
> subscription_type int NOT NULL,
> distribution_agent sysname NULL,
> time smalldatetime NOT NULL,
> description nvarchar(255) NULL,
> transaction_timestamp varbinary(16) NOT NULL,
> -- SyncTran
> update_mode tinyint NOT NULL,
> agent_id binary(16) NULL,
> subscription_guid binary(16) NULL,
> subid binary(16) NULL,
> immediate_sync bit NOT NULL default 1 -- sync_mode with a default of 1
> )
>
> CREATE TABLE dbo.MSsubscription_agents
> (
> id int identity,
> publisher sysname NOT NULL,
> publisher_db sysname NOT NULL,
> publication sysname NOT NULL,
> subscription_type int NOT NULL,
> queue_id sysname NULL,
> update_mode tinyint default 0 not null, -- 0 = read only, 1 =
> sync/immediate, 2 = queued, 3 = failover, 4 = sqlqueued, 5 = sqlqueued
> failover
> failover_mode bit default 0 not null, -- 0 - sync/immediate, 1 = queued
> spid int NOT NULL,
> login_time datetime NOT NULL,
> allow_subscription_copy bit default 0 not null,
> attach_state int default 0 not null, -- 0: not attached 1 attached but
> not processed 2 attached and processed.
> attach_version binary(16) default newid() not null,
> last_sync_status int NULL, -- allow null for upgrade
> last_sync_summary sysname NULL, -- allow null for upgrade
> last_sync_time datetime NULL, -- allow null for upgrade
> queue_server sysname NULL -- only used for MSMQ based updating
> subscribers
> )
> --
> Hilary Cotter
> Looking for a SQL Server replication book?
> http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTS
> http://www.indexserverfaq.com
> "Hassan" <fatima_ja@.hotmail.com> wrote in message
> news:%23TZtfkaXFHA.3712@.TK2MSFTNGP09.phx.gbl...
> MSsubscription_agents
>

Accidentally dropped DBO from database

I altered a script that drops all users from a database and accidentally
changes an AND to an OR so that the user DBO was dropped after a refresh fro
m
production to dev.
Can I readd this user or is the only solution is to restore from backup?
Thanks,
LindaYou can use sp_changedbowner and dbo will map to whatever
login you assign as the database owner with
sp_changedbonwer.
You can find more information on sp_changedbowner in SQL
Server books online.
-Sue
On Tue, 18 Jan 2005 06:25:03 -0800, "Linda"
<Linda@.discussions.microsoft.com> wrote:

>I altered a script that drops all users from a database and accidentally
>changes an AND to an OR so that the user DBO was dropped after a refresh fr
om
>production to dev.
>Can I readd this user or is the only solution is to restore from backup?
>Thanks,
>Linda|||The user dbo was dropped from sysusers. This did not solve the problem. I
ended up restoring the database from backup but that took several hours and
I
had been hoping a quick script to add dbo back to sysusers might solve it.
"Sue Hoegemeier" wrote:

> You can use sp_changedbowner and dbo will map to whatever
> login you assign as the database owner with
> sp_changedbonwer.
> You can find more information on sp_changedbowner in SQL
> Server books online.
> -Sue
> On Tue, 18 Jan 2005 06:25:03 -0800, "Linda"
> <Linda@.discussions.microsoft.com> wrote:
>
>|||Actually, what I suggested is exactly how you fix the issue.
Without any information on what happened or what errors you
had, it's hard to give you more specifics.
If you were receiving the error:
Error 21776: [SQL-DMO] The name 'dbo' was not found in the
Users collection. If the name is a qualified name, use [] to
separate the various parts of the name, and try again
That error is due to having databases where the owner (dbo)
is mapped to a login that doesn't exist on the server. It's
not a matter of DBO being dropped but rather problems with
the mappings.
If you get an error along the lines of "the user is already
a user in the database" when using sp_changedbowner, that's
generally due to a mismatch between dbo and the database
owner. You can work around this by creating a temp login,
change the owner to this new login, then change the owner to
the login you actually want to be the owner and drop the
temporary login.
-Sue
On Thu, 20 Jan 2005 08:57:06 -0800, "lslmustang"
<lslmustang@.discussions.microsoft.com> wrote:
[vbcol=seagreen]
>The user dbo was dropped from sysusers. This did not solve the problem. I
>ended up restoring the database from backup but that took several hours and
I
>had been hoping a quick script to add dbo back to sysusers might solve it.
>"Sue Hoegemeier" wrote:
>