SQL Server with Mr. Denny

Something that I think that Microsoft should include with the SQL Service Broker is an adapter so that MSMQ messages (and other messaging systems as well) will flow automatically into the SQL Service Broker. Since Microsoft hasn’t gotten around to writing one I’m going to start.

It shouldn’t be all that hard. Setup a Windows Service which reads from a predefined MSMQ and have it take the message and send it to a SQL Service Broker queue.

Then setup a Windows application that allows you to setup the config file with the source you want to read from and the SQL Service Broker objects you want to send to.

Since I have little to know experience reading from other queues I’m putting a feeler our there for some assistance on this project. Since I don’t know C#, the project will be written in VB.NET using Visual Studio 2008 on the .NET Framework v3.5.

I’ll be starting with MSMQ, and they other queuing systems as needed.

I’ve setup a project site on CodePlex. There’s not much up there at the moment, just a basic framework of the project. (Yes I know I now have two unfinished projects running, but this one will hopefully have others working on it as well.)

If you are interested in helping me out please let me know here, or on twitter, or in the discussion forum on CodePlex.

All to often we end up with duplicate rows in a table. The best way to keep duplicate rows out of the database is to not let them in. But assume that they are there. This bit of sample code shows how to delete those duplicate rows quickly and easily in a single statement. No temp tables required (I use a temp table to put the data into for example purposes). This code is for SQL 2005 and up as it uses some features which were introduced in SQL Server 2005. SQL Server 2000 would require a totally different technique.

Every server that can access the Internet or be access from the Internet, or that can be accessed from a computer that can access the Internet should have an anti-virus on it. Preferably a corporate wide solution like Trend Micro, McAfee, Norton, etc. so that the server reports back to a central server to make it easier to find out if a machine has a problem.

Next comes what should be scanned. I prefer to exclude the mdf, ndf, and ldf files. I don’t like to exclude the entire folder as this creates a hiding place where a virus could stick infected files. If possible have it exclude the mdf, ndf and ldf files from old the correct folders only. Even if a virus scanner wanted to scan the database files it wouldn’t be able to as the files are locked open by the SQL Server so that nothing else can access them. By not excluding the files all you are doing is throwing alerts to the monitoring server that files couldn’t be scanned.

Odds are a full scan doesn’t need to be done against the server all that often as the files on the hard drive of the server aren’t going to change all that often. Any virus that comes in from the network should be caught by the real time engine that is running at the time. You will want to do a full scan every once and a while (every couple of weeks or so) incase something came in over the network was saved and setup to launch at the next reboot but wasn’t yet in the virus definition file.

All to often I see people online asking some sort of question about connecting to their CoLo’ed SQL Server and they connect directly over the Internet. This is nuts people. If you can access your SQL Server via Management Studio from anywhere on the Internet so can people who would love to break into your SQL Server and use the machine for their own uses.

SQL Servers shouldn’t every be directly accessible from the Internet. Even if you have to use public IPs to host the machines, make sure that there is a firewall setup between that server and the public Internet so that no one has any sort of direct access to the machine from outside of the data center.

How do you manage the SQL Server in this case? You use the router’s built in functions to setup a point to point VPN with your office router so that you can securely communicate with the servers in the CoLo without sending that data in plain text over the Internet.

For that matter while you are locking down the SQL Server, suggest that the Web Servers be locked down as well. The only ports that they should have open are 80 and 443 unless you are running streaming servers, or known FTP servers.

If your servers have been sitting exposed on the public Internet then I highly suggest that you install an Anti-virus on them and check for Viruses, malware, etc that’s doing stuff you don’t want it to be doing.

Several years ago I was doing some work for a company that had Windows 2003 servers sitting directly on the Internet without an Anti-Virus and with no firewall. When I got to the machines and took them off the Internet for cleaning there were over 200 viruses on the machines that they had no idea were on there. There complaint was that the machines were running slow, and network costs kept going up. God only knows what sort of network traffic these viruses were generating as they did what ever it was they were trying to do.

Microsoft SQL Server 2005 and 2008 Standard edition will be getting the Lock Pages in Memory feature that SQL Server Enterprise Edition has had starting in SQL Server 2005. This was announced by Bob Ward via the CSS Blog in his post “SQL Server, Locked Pages, and Standard SKU…“. Per Bob’s post a CU will be released for SQL 2005 SP3 and SQL 2008 SP1 which will allow for a trace flag to be used to turn this feature on.

On behalf of the users I’d like to thank Bob and the rest of the SQL Server team for being able to get this into the product.

On behalf of the developer team, I emplore you to not turn this on for no reason. Only use this feature once you understand what this feature does and in the correct places.

The Locked Pages flag bascially tells the SQL Server that if it is told to flush RAM to disk to ignore it. If the setting is enabled then SQL doesn’t flush to disk. If you find that your SQL Server is flushing to disk, don’t just enable the flag and move on. I emplore you to contact CSS and figure out why SQL is being told to flush to disk. This is the only way the bug will be fixed. Once the issue has been reported to Microsoft and they have the information they need enable the flag until the bug is fixed. Then install the patch to fix the bug, disable the flag and you’ll be fine.

Because of the fact that this is how bugs are found and fixed I hope that this is a CSS only CU which will require that users contact CSS before they can get the fix.

There’s a new SQL Server 2008 MCTS Certification book on the market. It is “The Real MCTS SQL Server 2008 Exam 70-432 Database Implementation and Maintenance“. I normally don’t post book releases as there are a lot of new books coming out these days. However I published this one because I wrote part of it. The book is a complitation of several authers work, and I wrote three of the chapters in the book.

So if you are looking to get your MCTS Certification I’d recommend that you check it out.

This is my first book credit (though not listed on Amazon), and there will be a second one from the same publisher coming out soon.

One of my developers came to me asking me to add more RAM to the c++ build server. However the machine was already at 2 Gigs so I wasn’t sure if adding more RAM wouldn’t help. Turns out that VS 2005 doesn’t support AWE so adding more RAM wasn’t going to be of much help. Until I found a post by Steve Harman entitled Hacking Visual Studio to Use More Than 2Gigabytes of Memory.