Blog Home  Home Feed your aggregator (RSS 2.0)  
The Johnnynine Weblog - Tuesday, July 31, 2007
A weblog by Johnny Hughes
 
 Tuesday, July 31, 2007

THIS WAY HAS WORKED WELL FOR ME:

The easiest way I have found to immediatley shrink the log file is to detach the database, rename the .LDF file then reattach the .MDF file. In SQL Server 2005 you'll need to remove the missing .LDF file from the list before attaching, and one will be created for you.

 

I DID NOT GET THIS ROUTINE BELOW TO WORK WITH SQL SERVER 2005:

 

From the April 2001 edition of SQL Server Magazine:

 

Shrinking Log Files Immediately

You can use the DBCC Shrinkfile statement in SQL Server 7.0 to shrink the size of a specified data file or log file for a related database. But SQL Server professionals often ask me why the DBCC Shrinkfile command doesn't shrink the size of their transaction logs immediately and how to make their transaction logs smaller.

SQL Server 7.0 doesn't immediately shrink log files when you issue the DBCC Shrinkfile command. The DBCC Shrinkfile operation occurs only at checkpoints or transaction log backups. SQL Server segments each physical log file internally into a number of virtual log files (VLFs), which make up the transaction log. SQL Server marks the VLFs as truncateable either after SQL Server has backed them up or at checkpoints. At any given time, you might have VLFs with free or reusable space at the beginning, middle, and end of the log. Only when the VLFs that SQL Server marked as truncateable are at the end of the log file can the DBCC Shrinkfile operation remove the VLFs and shrink the log file. Because SQL Server can shrink a log file only to a virtual-log-file boundary, you can't shrink a log file to a size smaller than the size of a virtual log file—even if you aren't using the log file. (For more information about virtual log files, see SQL Server Books Online—BOL.)

Listing 1 shows a script that shrinks the log file immediately after you stop running the script. The script first marks a shrinkpoint, which tells the DBCC Shrinkfile (or the DBCC Shrinkdatabase) command where to shrink the log file to. The script then forces truncateable VLFs to the end of the log file and issues a BACKUP command to truncate the log. In my experience, you need to run the script for 3 to 4 minutes before stopping it manually.

—Simon Su  yqsu@microsoft.com

 

Listing 1: Script to Shrink a Log File

/* Run "SELECT fileid, name,filename FROM <db_name>..sysfiles" to get
the fileid you want to shrink. */

USE <db_name>
GO
DBCC shrinkfile(<fileid>,notruncate)
DBCC shrinkfile(<fileid>,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 <db_name> with truncate_only
END
GO
Tuesday, July 31, 2007 5:39:29 PM (US Mountain Standard Time, UTC-07:00)  #    Comments [0]   Database | Sql Server  | 
 Friday, June 15, 2007

From microsoft.com:

"Beginning in Exchange 2007 Beta 2 and Outlook 2007 Beta 2, CDO 1.2.1 will no longer be provided as a part of the install of the product. As a result, there is functionality missing that many applications depend upon. CDO 1.2.1 is a package providing access to Outlook-compatible objects through a COM-based API."

You can download Collaboration Data Objects, version 1.2.1 from microsoft here.

Just as a note, CDO was included as an optional accessory starting with Outlook 2000-ish.

Friday, June 15, 2007 4:00:16 PM (US Mountain Standard Time, UTC-07:00)  #    Comments [0]   Fixes | Technical  | 
 Tuesday, May 29, 2007

EXEC sp_rename 'tablename.oldindexname, tablename.newindexname', 'INDEX'

 

Don't forget the tablenames.

Tuesday, May 29, 2007 6:03:44 PM (US Mountain Standard Time, UTC-07:00)  #    Comments [0]    | 
 Friday, May 18, 2007

I'm always forgetting my dsn-less connection string formats.

 

VB6:

Oracle:

Provider=OraOLEDB.Oracle.1;Data Source=tnsname;User Id=userid;Password=password;

 

Sql Server:

Provider=sqloledb;Data Source=servername;Initial Catalog=dbname;User Id=userid;Password=password;

.Net

Oracle (OracleClient):

Data Source=tnsname;User ID=userid;Password=password;

 

Sql Server (SqlClient):

Server=servername;Database=dbname;User ID=userid;Password=password;Trusted_Connection=False

Friday, May 18, 2007 10:26:15 PM (US Mountain Standard Time, UTC-07:00)  #    Comments [0]    | 
 Monday, December 04, 2006

If you want access to the individual files within your complete pc backup, then the built in Complete PC Backup in WIndows Vista isn't for you.  You can only restore your complete partition.

A caveat to the above is that I have heard you can mount the above backup file in Microsoft Virtual PC as a harddrive, which in theory would allow access to the individual files however this would require you have Virtual PC installed and I have not tried this.

Acronis True Image 10 is compatible with Windows Vista and allows you to explore the backup files in explorer.

Tuesday, December 05, 2006 5:08:37 AM (US Mountain Standard Time, UTC-07:00)  #    Comments [0]    | 
Copyright © 2008 Johnny Hughes. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.