Tag Archive: MSSQL

Remote MSSQL…oh, you imbecil! :)


Not very often, you will get the following error:

Error:
The server principal “” is not able to access the database “” under the current security context.

This is because the MS SQL Server is attempting to execute a SQL query to retrieve a list of databases along with  some other formation about those databases. Some of  that information is “Collation”, which, ofcourse you don’t have permission to view for all databases, since  you’re in a shared hosting environment and you can only have access to your database..

Solution is pretty straight forward :
1. In Object Explorer, click on Databases
2. Display Object Explorer Details (F7) or View > Object Explorer Details
3. Right click the column headers and de-select “Collation”

4. Refresh Databases or reconnect to ste machine.

Thats it :)

 

Bye bye  :)

So…today I had a very interesting issue. All of a sudden Nagios went red with the message: CRITICAL : – total: 232.82 Gb – used: 212.67 Gb (91%) – free 20.15 Gb (9%) on one of our SQL server. I was like..”NO! It cannot be. I clearly remember that this machine had over 150 Gb of free space yesterday!”

I log in to the machine, and automatically go to the data folder of SQL server thinking that some customer has a HUGE! log file on his database; so, right click – Select All -> Properties… only 50 Gbs of data…hmm…not here!

At that moment I notice that the server isnt “jumpy” as usual, so I start Performance monitor and see that the Avg. Disk Queue is off the chart!  That definatelly isnt right…

Since that machine is using Windows 2003, theres no too good way to see what application is using so much disk I/O ( beside FileMon ) , I start the FileMon and se that the SQL service is writing HUGE amount of data to its ERRORLOG file.

By navigating to the folder, I see that the ERRORLOG file is over 120 Gb big so opening it in Notepad, Context or some other file was out of the question, since it would kill the machine completely.

So, lets turn to powershell once more. In order to be sure to not kill the machine, since its in production , I have moved the file to an empty machine to opened it there.

Powershell : cat errorlog +ENTER :) after that powershell started to list the entire content of the file, and it took about 15 mins until it reached the end. AMAZING

By examining the log, I notice ( it was hard to NOT notice it ) litterally millions of these entries:

Could not allocate space for object ‘dbo.tblComments’.'tblComments’ in database ‘DATABASEname’ because the ‘PRIMARY’ filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.

What happened here?

The site that was using that database is poorly written and was allowing everyone to post comments on the articles without any security check, so it soon reached the size limit set on the database.  By further digging on the issue, I saw that the bots are posting about 4-5 comments each second which comes to about 18000 comments/hour…multiply that by 15-16 hours it took to fill the error log to that size, we roughly come to 280000 comments…that’s A LOT of comments! :)

After disabling the site and sending the email to the customer, situation on the machine looks like this :

The big drop on the green line is the moment where I disabled the problematic web site.

mssql-logoMicrosoft SQL Server 2005/2008 Express is a free edition of SQL Server that is ideal for learning, developing and powering desktop, web and small server applications, and for redistribution by ISVs.

Top Features

  • Supports stored procedures, triggers, functions, and views
  • Store all kinds of business data with native support for relational data, XML, FILESTREAM and spatial data
  • Improved performance, usability, visualization, in addition to integration with the Microsoft 2007 Office System in SQL Server Reporting Services
  • Simplify development efforts by leveraging existing T-SQL skills, ADO.NET Entity Framework and LINQ
  • Closely integrated with Visual Studio and Visual Web Developer

Because there’s no “SQL Agent” in SQL Express Editions, in order to create scheduled backups on SQL server Express edition, we need to user couple of tricks  :)

Hello there…

In order to  install SQL 2008 Express, we have to download it first . Fire up your favorite browser and point it to http://www.microsoft.com/express/download/ . After that, find the box with the SQL 2008 Express, and click download.

sqlexpress

On the next step you have the option to register with Microsoft or download the software without registration.  I will choose the “no registration part”.

sqlexpressdownloadpage

In the new window, choose the version you would like to install. Personally, I will choose “Runtime with advanced services“. By clicking on install, Microsoft will ask to install the Microsoft Web Platform installer. If you dont have it installed, click on the picture to install it.

webplatforminstaller

Choose “Run”, and after the download, again, choose “Run“. Wait for the installtion to finish and look at the top of the browser, a little bar will pop up and ask us if we want to run Active X control.  Make sure the publisher is “Microsoft Corporation”. Click on “Run“, and then on Allow.

Now, look at the video of the installation I have made for you. The video will show you the process of installing SQL Server 2008 Express.

After that, all you need to do is run the “SQL Server Configuration Manager” under “Configuration Tools” and configure it the way you want it.

BTW, the track used is La Noche by Coca & Villa .IT’s AWESOME!!!

Have fun…bye!

Hi, last couple of days I have setuped over 10 Windows 2008 servers for hosting services for testing or production, so I am pretty bored with repeating the same stuff all over again :) , but, here’s a recorded video tutorial of one installation process. Because the video is pretty straightforward, I’ve decided that there is no need to explain every step of the installation.

Click on the HD button and put the video into full screen mode, so you can see all the details.

In the next post, I will show you how to install Microsoft SQL server 2008 Express .

Cheers!