Truncate Logs for SQL Server 2008


I had previously posted how to Truncate Logs for SQL Server 2005. Unfortunately, this method does not work in SQL Server 2008. The reason is because the “WITH TRUNCATE_ONLY” command is no longer in SQL 2008. Assuming you run in full recovery mode, the new script to do this is:

1
2
3
4
5
6
7
8
USE [{DatabaseName}]
GO
ALTER DATABASE [{DatabaseName}] SET RECOVERY SIMPLE
GO
DBCC SHRINKFILE({TransactionLogLogicalName})
GO
ALTER DATABASE [{DatabaseName}] SET RECOVERY FULL
GO

Simply setting the database mode into simple recovery mode performs the actual truncation but the file is not shrunk by that. DBCC SHRINKFILE will take care of that second step. And don’t forget to put it back into full recovery mode at the end!!

-Shane



IndyTechFest registration is now open!


IndyTechFest registration is now open! This year there is a limit of 500 registrations (I believe last year’s was like 400 and it was booked up within just a couple weeks). So I strongly encourage you to register sooner rather than later!

There is a great lineup of speakers and sessions at this year’s IndyTechFest! Some of the speakers I have seen speak before include Paul Hacker, Larry Clarkin, Michael Eaton, Arie Jones, Tom Pizzato, Dan Rigsby, and Bill Steele. There are many other great speakers that I know or have heard of. This should be an excellent event and one that is worth a good long drive to get to!

Some of the sessions that I’m really looking forwards to include Test Driven Development (TDD) w/ VS 2008, Tips and Tricks for the New C#, Tips and Tricks for the New VB .NET, Duplexing WCF in the Enterprise, and Virtualization of SQL Server. There are many other sessions that I’m going to hope to get to but alas, with it being a one-day event, I doubt I’ll get to most of the ones I really want to see. :P

Props to the people who worked hard to make this event possible, including Brad Jones, Dave Leininger, John Magnabosco, Mark McClellan, and Bob Walker, as well as all of the support of the local user groups to help drive the event!

Just as I was wrapping this post up, I received a phone call. Apparently as of 1pm (1 hour after registration opened), nearly HALF of all available registration slots were filled! If you read this post and have not registered, go register NOW and don’t wait or you’ll be left out!



Indy Invades CinArc!!


On Tuesday (July 8, 2008) evening, Sasha Kotlyar, Dean Weber, and I made a spontaneous trip to Cincinnati to check out the CinArc group (not to be confused with this CinARC). This group is Cincinnati’s Architecture User Group and seems to be mostly .NET-based. They are a very new group as this was only their second meeting. They meet monthly on the second Tuesday of the month. Their current meeting-format is that of a fishbowl meeting. You can read more on Wikipedia about this here.

I must say, the three of us Hoosiers really enjoyed ourselves at CinArc! Despite the downpours, rush-hour construction, and construction barrels we had to dodge in the middle of the road, it was great! Oh, and I won a door prize as well! I walked out with a VS2008 Pro license (only had MSDN-based licenses before, now I have a permanent license!). The group is led by Mike Wood, who also happens to lead the Cincinnati .NET User Group. Lots of other people were also in attendance (I’m not even going to attempt to name them because I’m horrible with names and I’ll surely forget some of them but turns out I follow lots of them on Twiter). There was a total of 19 people there with 5 chairs in the middle of the fishbowl (1 moderator, 3 speakers, 1 open). It was great that they veered away from the norm where it was a very interactive discussion and almost everybody participated in it.

The agenda for the meeting was different than what I’ve been used to for user group meetings, and I really liked it! I’m used to food before hand, kicking things off with announcements, then going into the discussion for the rest of the night, and door prizes at the end. What they did, instead, was kick things off with the discussion, about an hour into it take a break for food, kick the second half off with announcements, go back into the discussion after the nice little break, and then door prizes at the end. The trick to accomplishing this is timing on the food and if it can be pulled off, I may actually try to assimilate this style into the ALT.NET meetings! However, one important part of the ALT.NET meetings, I feel, is the social time spent before the meeting. Perhaps we can have snacks and drinks available then and real food available at “Halftime”.

One other thing that was really neat was that the meeting attendees were able to choose the topics to discuss. Ideas were put up on a whiteboard as recommended by the people there, and then everybody voted on the ones that they were most interested in participating in discussion with. There were 3 topics that seemed to be the most popular, and it turned out that we had time to discuss 3 topics. So it worked out perfectly!

As I said before, I had a great time at CinArc and I highly recommend it to anybody who is in the area and is interested in best architecture practices and bouncing ideas off of one another! There were some extremely intelligent guys at this group and it’s great that they are trying to expand knowledge in the community and help one another! I can already see this is going to be a very popular user group in the future! I hope some of those guys come visit some of our Indy events, and I just may try and pick up some Reds tickets some second Tuesday of the month afternoon so I have a good excuse to be in town again for another CinArc meeting! :)

-Shane



Truncate Logs for SQL Server 2005


I’m frequently trying to figure this out but never remembering the exact syntax, so here it is! A quick/easy way to truncate logs on a database via script!

* NOTE: I don’t recommend this for production databases unless you tweak it to be good. This is more for dev environments where you don’t really care about transaction logs!

1
2
3
4
5
USE [{DatabaseName}]
GO
DBCC SHRINKFILE({TransactionLogLogicalName}, 1)
BACKUP LOG [{DatabaseName}] WITH TRUNCATE_ONLY
DBCC SHRINKFILE({TransactionLogLogicalName}, 1)

Happy truncations!

-Shane



IndyALT.NET Site is live!


IndyALT.NET is now live!

Right now it’s being hosted in somebody’s house (thx to Paul Hacker, MSMVP, for sharing his servers temporarily!) We’re excited about our first two events! Next month we’re having Mike Griffin come in for some training on the EntitySpaces OR Mapper. In July we are planning on having Todd Anglin come in and show us some good stuff with some of Telerik’s products. And who knows what else we’re going to do!

Interesting and busy times to come!

-Shane



Exclusive access for Database Restores on SQL Server 2005


How many times have you tried to run a database restore on SQL Server 2005 only for it to fail because you don’t have exclusive access to the database (for whatever reason from SSMS being open to anything else)? Happens to me quite frequently. Here’s a handy piece of code to help prevent that:

1
2
3
4
ALTER DATABASE xxxxxxxxxx SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
-- Your restore script here.
ALTER DATABASE xxxxxxxxxx SET MULTI_USER WITH ROLLBACK IMMEDIATE;
GO

What this does is sets the database into single-user mode (which effectively kills all other connections to it), restores the database, then when it’s done it sets it back to multi-user mode. I LOVE using this for restores that I seem to do over and over. :)


Jaxidian Update is proudly powered by WordPress and themed by Mukkamu