Friday, April 13, 2012

Rename a Computer that Hosts a Stand-Alone Instance of SQL Server

Have you ever renamed a windows server after installing SQL server on it? Well, sql still holds the old name if you run select @@servername.
So, there are a few steps to follow after the rename. First, allow master (system database ) to see the new default instance name. Second, restart the database engine.

Open new query windows or sqlcmd:

use master
go

sp_dropserver
GO
sp_addserver , local
GO

Thursday, April 5, 2012

Cannot delete job | The DELETE statement conflicted with the Foreign


I got a call from user today who was trying to delete a job from sql agent. The problem is that the maintenance plan still exist. So, you should delete the parent( Maintenance plan) before attempting to delete the child (JOB). However, Microsoft doesn't give you a clear error.
Cannot delete job The DELETE statement conflicted with the Foreign Key-- Read more: http://www.sqldbadiaries.com/2010/11/11/cannot-delete-job-the-delete-statement-conflicted-with-the-foreign-key/#ixzz1qzPlu15d