Accidental Technologist

Entries categorized as ‘SQL Server’

Fixing the Toolbox in Visual Studio 2005

March 20, 2008 · Leave a Comment

I have had the extreme pleasure of working with Microsoft SQL Server 2005 Reporting Services lately (notice the extreme sarcasm in my tone).  I am working on a project for a large client and one part of the project requires I enhance a report to support multiple languages.   This post is not about localization but a rather strange issue I faced today.

I opened up my project in Visual Studio and proceed to open the report I needed to analyze for changes and decided to look at the controls at my disposal to help enhance the report and was greeted by this set of controls:

ReportingServicesToolBoxBefore

Interesting, all the controls are just Textbox.  Obviously this isn’t right and I had to do a bit of searching around the net for a few things to try.  The first suggestion I found was to right click the Toolbox and select Reset ToolBox….this had no effect.  Several suggestions didn’t seem right but I finally tried one which worked.  It involved a few steps:

  1. Shutdown Visual Studio
  2. Locate the directory – C:\Documents and Settings\<user name>\Local Settings\Application Data\Microsoft\VisualStudio\8.0
  3. Delete all files named Toolbox.* (there were 4 of them)
  4. Restart Visual Studio

The directory listing where the Toolbox files live looked like this:

VisualStudioToolBox

When Visual Studio restarts it will recreate the Toolbox files based on what is installed on the system.  After restarting Visual Studio my Toolbox looked like this when editing a report:

ReportingServicesToolBoxAfter

The steps are pretty trivial when you know what they are but finding the solution took a bit of spelunking but it worked like a charm.  I don’t know what actually caused this to happen but I don’t have the time to find out why.  If someone has the reason I would love to know why.

Categories: .NET · SQL Server · Visual Studio

Microsoft SQL Server 2005 Replication Automation Resources for SQL Management Objects (SMO)

August 22, 2007 · Leave a Comment

Background

I have recently been involved in a project which makes heavy use of Microsoft SQL Server 2005.  We have many database servers all over the company including several clusters with locations all over the world.

My role on the project is to be able to synchronize all of the databases across the company so each database has the same information in it as close to real-time as we can.  I decided to use SQL Replication Services in a transactional push configuration.    I used this method in a test environment and found the performance to be very good and the results very reliable.

Setting up SQL Server Replication is pretty straight forward using SQL Management Studio as the wizards guide you through the entire configuration.  I had about 100 tables that needed to be replicated out of about 250 tables, selecting them was where it became a bit time consuming but setup was still easy.

The Challenge

The replication solution was to run in a development environment during the later parts of system development so we could see the behavior of replication from both a performance and latency standpoint.  The results were extremely fast even across the Atlantic Ocean, we are talking milliseconds here for changes to data.

The challenge we faced came about when we needed to make schema changes on the server who was the replication source (publisher).  The process we use is to compare the old schema to our new schema and generate a SQL script to execute on the replication source database.  Prior to using replication we had no trouble performing this task but with replication running there is a problem when changing an existing column in a table, SQL Server will NOT allow it.  The issue stems from the fact that SQL Server drops the column and re-creates the column with the changes, which cannot happen to replicated tables.

The Solution

So, the way I approached this problem was to be able to easily remove replicated tables from a publisher, make schema changes and re-create the replication.  This is a straight-forward but tedious task using SQL Management Studio but is error-prone and tedious.

I started looking at using SQL Management Objects (SMO), which I had used on another project for automating other SQL tasks.  I discovered SMO has a subset of classes call Replication Management Objects (RMO) that are designed just for this task.  The only problem I faced was learning how to use them in a timely manner and be able to write the code to do all that was needed.

The key part to learning to use RMO is to learn how SQL Server Replication is designed and how it works.  Once this is understood, it is pretty easy to see how RMO maps to how SQL implements replication. 

It took a bit of effort to find the right resources on the web to learn how RMO works and locate the resources to turn to if I had a question.  The main point of this post is not what I did but more of the resources I used to build my solution.

The Resources

Most of the information I found and used was directly from Microsoft’s MSDN web site but provided here to help group them together.

Transactional Replication Overview – learn what it is all about.

Configuring Replication (RMO Programming) – probably the best resource for writing an RMO application based on C# or VB.NET.

Microsoft SQL Server Replication Forums – good to read about those who have done it and get answers relatively fast.

MSDN Magazine Article – great way to get started.

Making Schema Changes on Publication Databases – what you need to understand.

The tool I use for comparing databases is SQL Compare from Red Gate Software.   This tool is great, easy to use and allows the user to save it’s results in a SQL script.  Red Gate has released SQL Toolkit which allows for managing replication and some other things.  I have not looked extensively at this product but it may wrap RMO and make it a bit easier to automate your RMO tasks.

All in all RMO is a great way to programmatically manage replication in your application.  It does have a bit of a learning curve, as does any new technology, but once over the curve it works really well. 

Technorati Tags: , ,

Categories: .NET · SQL Server

Online Database Schema Library

July 13, 2006 · Leave a Comment

I came across this Library of Free Database Models from Scott Guthrie’s blog recently.  Below is an example of one design I did in the past months this source would have been extremely helpful.

If you are starting a new project of expanding one this resource should prove to be a great place to start when thinking about your schema design.

 customers_campaigns_ecommerce_dezign.gif

Technorati Tags : ,

Categories: Programming · SQL Server

Red-Gate Software Releases SQL Prompt

May 23, 2006 · Leave a Comment

Red-Gate Software recently acquired a product called SQL Prompt. SQL Prompt gives the SQL developer intellisense in SQL Query Analyzer and SQL Management Studio, which all Visual Studio developers are spoiled with.

I have been using the version from the previous developer for some time now and really got used to using it. It gives nice intellisense menus every where Microsoft did not. It baffles me why Microsoft has done such a great job with Visual Studio Intellisense but left it out in MS SQL Server 2005.

Red Gate just announced the first release of SQL Prompt is available since they acquired it and they are making it FREE. Yes, free until September 1, 2006. It's a full version and will not cease to run after September 1.

Since I started using SQL Prompt several months ago, I have really gotten used to using it and it is so much like Intellisense in Visual Studio. I am hoping Red-Gate continues to improve this product as it really fills a gap in being an efficient SQL developer.

I am a big fan of Red-Gate Software, since relying on their SQL Data Compare and SQL  Compare products.   

Technorati Tags : , ,

Categories: .NET · Programming · SQL Server

Microsoft SQL Server Management Studio Express Edition

December 19, 2005 · Leave a Comment

The recent release of Visual Studio 2005 came with it the express edition of SQL Server 2005.  This is a trimmed down version of the full SQL Server 2005 we have all been waiting for but it’s included in the box.

One of the main drawbacks to the Express Edition is the lack of a tool we are all used like Enterprise Manager from SQL 2000.  Sure, you can use Server Explorer in VS 2005 and do some management of stored procedures, views and such but not the management we are all used to.

Enter Microsoft SQL Server Management Studio Express Edition, which provides a graphical management tool for SQL Server Express databases, with a bonus, you can also manage SQL Server 2005 databases as well.

Below you can see a screen shot of the main window.  What a great tool, and it’s free.  After using it for a few days I can say the interface is so much more enjoyable than the old SQL Server 2000 Enterprise Manager I have been using for the last few years.

Sqlexpress

Technorati Tags: ,

Categories: SQL Server