Friday, March 13, 2009
The Return of the Living Dead:Job Owners who Keep Coming Back
UPDATE
msdb.dbo.sysdtspackages90
SET
OWNERSID = SUSER_SID('DOMAIN\new_user')
WHERE
OWNERSID = SUSER_SID('DOMAIN\old_user')
For SQL Server 2008, this query should do the trick
UPDATE msdb.dbo.sysssispackages
SET OWNERSID = SUSER_SID('DOMAIN\new_user')
WHERE name = 'MaintenancePlan' AND OWNERSID = SUSER_SID('DOMAIN\old_user')
There's currently a Microsoft Connect item for this case so feel free to vote on it if you think it's worth having a solution that just a workaround
Tuesday, March 10, 2009
How to immediately shrink the SQL Server log files
- Backup the transaction log. This will truncate the log
- Shrink the log file
Pretty simple, right? Well, there are times when this might not work because SQL Server does not shrink the log immediately. The DBCC SHRINKFILE operation occurs only at checkpoints or transaction log backups. SQL Server divides each physical log file internally into a number of virtual log files (VLFs), which make up the transaction log. This MSDN article describes virtual log files in SQL Server. SQL Server MVP Tibor Karaszi highlights why you would not want to shrink your log files. This blog by Johnny Hughes has a script that lets you do this task.
USE databaseName
GO
DBCC shrinkfile(<file_id>,NOTRUNCATE)
DBCC shrinkfile(<file_id>TRUNCATEONLY)
CREATE TABLE t1 (CHAR1 CHAR(4000))
GO
DECLARE @i INT
SELECT @i = 0
WHILE (1 = 1)
BEGIN
WHILE (@i < 100)
BEGIN
INSERT INTO t1 VALUES ('a')
SELECT @i = @i +1
END
TRUNCATE TABLE t1
BACKUP LOG databaseName WITH TRUNCATE_ONLY
END
Are you a SQL Server DBA wanting to Learn Windows PowerShell?
This article is a first in this series of introducing Windows PowerShell to SQL Server DBAs. Go check it out