Tuesday, January 5, 2010

Error 14151:Replication Agent failed to start.

Error:The SQL Server Replication Agent may not start, and you receive the following error message:
The replication agent is not registered properly. Rerun SQL Server setup. The step failed. [SQLSTATE 42000] (Error 14151). The step failed.
Cause:

The Replication Agent that is running on the server may not restart when a named instance of SQL Server is removed from the server and replication is configured on the server. When you remove a named instance of SQL Server, the registry entries that relate to the Replication Agent are removed from the server. This behavior may also occur when the 8.3 name creation on the NTFS file system partition is disabled on the computer where SQL Server is installed. You disable 8.3 name creation on the NTFS partition by setting the NtfsDisable8dot3NameCreation registry key to 1.
Solution:
To work around this problem, follow these steps:
1-Set the NtfsDisable8dot3NameCreation registry key to 0.
To change the registry key, use these steps:
2-On the Start menu, click Run. Type regedit, and then click OK.Locate the following key in Registry Editor:
HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\FileSystemDouble-click the NtfsDisable8dot3NameCreation key of type REG_DWORD.Set the Value Data of the registry key to 0, and then click OK.
Note: By default, the value for the entry is set to 0. Close Registry Editor.

3-Restart your computer.

Use one of the following methods to register the replication agents:
Method -1

Re-register the Replication Agent executables. To do this, use these steps:
1-Stop the SQL Server Agent service.

2-Copy the following command to a batch file:
snapshot.exe -regserver

distrib.exe -regserver

replmerg.exe -regserver

logread.exe -regserver

qrdrsvc.exe –regserver
3-Run the batch file you created in step 2b from the \Microsoft Sql Server\80\Com folder.

4-Restart the SQL Server Agent service.
Method 2-

Rebuild the registry. To do this, use these steps:

Insert the Microsoft SQL Server 2000 disk in the CD-ROM drive. If the disk does not run automatically, double-click Autorun.exe in the root directory of the disk.Click SQL Server 2000 Components, and then click Install Database Server.In the Welcome screen of the SQL Server Installation Wizard, click Next. In the Computer Name dialog box, click Next.In the Installation Selection dialog box, click Advanced Options.In the Advanced Options dialog box, click Registry Rebuild, and then click Next. You will see a message that informs you that Setup rebuilds the registry based on information you supply in the subsequent screens.


Caution: You must enter the same choices for the setup options as you did for the initial installation. If you do not know or are not sure of this information, do not use this registry rebuild process. Instead, you must remove and re-install SQL Server to restore the registry. To prepare for the registry rebuild, enter the same information and options that you entered during the initial installation of SQL Server in the setup screens as they appear.
Note: Rebuilding the registry includes re-copying external components such as Microsoft Data Access Components (MDAC) and Microsoft Distributed Transaction Coordinator (MS DTC).

Friday, January 1, 2010

Rebuild and Restore Master database

How do you know if your master database is corrupt?

Let's pretend that your company had a power surge and your SQL Server rebooted. Upon reboot, SQL Server would not start. If you check the error log , you'll see that the master database is either corrupt or missing.Rebuild your master database:
Your first step in recovering your master database is to use the Rebuild Wizard (Rebuildm.exe), located in the \Program Files\Microsoft SQL Server\80\Tools\BINN directory. Let’s walk through the Rebuild Wizard to see how it works.Start by double-clicking Rebuildm.exe to bring up Rebuild Master screen.
On this screen, you can specify the collation settings of your database server and the location of your data files during your original install. To make the latter easier and faster, copy the x86 directory from the SQL CD to your hard drive and point to the local copy. Once you have verified all of this information, click Rebuild. You'll then be prompted to confirm the operation,
Click Yes. Once the process is completed, you'll see a message telling you that the rebuild was successful. You now have a brand new master database and are ready to restore your master database.

Restore Master db with a Backup file:First, start SQL Server in single-user mode by opening up a command prompt and issuing the command sqlservr.exe –c -m from the \Program Files\Microsoft SQL Server\MSSQL\BINN\ directory.

After you start SQL Server in single-user mode, you can restore your master database from a backup. You can restore it using either the Query Analyzer or SQL Enterprise Manager.

If you're using Enterprise Manager, right-click on the master database, choose All Tasks Restore Database, and browse to where your device is located, . Click OK twice, and you have successfully restored your master database.
Once you've restored your master database, exit single-user mode and restart SQL Server in normal operation mode.If for some reason your restore operation does not work, you can try an alternative method. Simply rebuild the master database and attach all of your databases that reside in the data directory. You can attach the databases using Enterprise Manager or Query Analyzer. In Enterprise Manager, right-click on Databases and choose Attach Database.

Rebuild and Restore Master database

How do you know if your master database is corrupt?

Let's pretend that your company had a power surge and your SQL Server rebooted. Upon reboot, SQL Server would not start. If you check the error log , you'll see that the master database is either corrupt or missing.Rebuild your master database:
Your first step in recovering your master database is to use the Rebuild Wizard (Rebuildm.exe), located in the \Program Files\Microsoft SQL Server\80\Tools\BINN directory. Let’s walk through the Rebuild Wizard to see how it works.Start by double-clicking Rebuildm.exe to bring up Rebuild Master screen.
On this screen, you can specify the collation settings of your database server and the location of your data files during your original install. To make the latter easier and faster, copy the x86 directory from the SQL CD to your hard drive and point to the local copy. Once you have verified all of this information, click Rebuild. You'll then be prompted to confirm the operation,
Click Yes. Once the process is completed, you'll see a message telling you that the rebuild was successful. You now have a brand new master database and are ready to restore your master database.

Restore Master db with a Backup file:First, start SQL Server in single-user mode by opening up a command prompt and issuing the command sqlservr.exe –c -m from the \Program Files\Microsoft SQL Server\MSSQL\BINN\ directory.

After you start SQL Server in single-user mode, you can restore your master database from a backup. You can restore it using either the Query Analyzer or SQL Enterprise Manager.

If you're using Enterprise Manager, right-click on the master database, choose All Tasks Restore Database, and browse to where your device is located, . Click OK twice, and you have successfully restored your master database.
Once you've restored your master database, exit single-user mode and restart SQL Server in normal operation mode.If for some reason your restore operation does not work, you can try an alternative method. Simply rebuild the master database and attach all of your databases that reside in the data directory. You can attach the databases using Enterprise Manager or Query Analyzer. In Enterprise Manager, right-click on Databases and choose Attach Database.

Friday, December 25, 2009

Move all DTS Packages between servers.

We can move all DTS packages from one server to another server through given two methods:
Method1:

If you save your dts packages under local packages, they are stored in the msdb.dbo.sysdtspackages table.
1) create a new dts package with connections to the two servers
2) create a datapump between the connection
3) because you cannot select the sysdtspackages table from the pull-down list, you need to use disconnected edit to manually modify the datapump to set the SourceTable and the DestinationTable to [msdb].[dbo].[sysdtspackages]
4) now close the disconnected edit
5) choose properties of the datapump and let dts perform the auto-mapping in the transfermations tab.
6) run it!
This will transform the rows in sysdtspackages from one server to the other, and PRESTO! All the packages have been moved, including all the version history!You could also set up a source query to select specific packages based on the name, or only the current version based on the create date.

Method 2:
Quite easy step!!!!!!1
--restore msdb db with msdbnew name from from source server to the target server then run below script:
insert into sysdtspackages ( name, id, versionid, description, categoryid, createdate, owner, packagedata, owner_sid, packagetype)
select name, id, versionid, description, categoryid, createdate, owner, packagedata, owner_sid, packagetype from msdbnew..sysdtspackages /* this is msdb from old server*/

Tuesday, December 15, 2009

Database is in transition

This issue comes when you tried to make your database offline and during this process you run the cmd sp_who2.There are some transactions in process and you try to make database offline, then you will have to sit with patience while SQL Server successfully abort/commit all transactions on backend and make it offline successfully meanwhile if you will try to access the database then get the msg, "Database is in transition", if you cannot sit with patience then just kill the thread from Activity Monitor where you see the command alter database set flat offline the other option is to restart the sql server, but in case of restart, it will not give you control of database, after restart the database will go in auto recovery mode, but after some minutes and this successful recovery you will be able to do any operation on database.