Logging all queries executed on MSSQL database

Submitted by Jochus on Sat, 30/03/2013 - 18:00 | Posted in: Database
Posted in

Related to this blogpost, I wanted to log all queries executed on a Microsoft SQL Server database.

This can easily be done by the SQL Server Profiler, which gets shipped with the SQL Studio Express application of Microsoft.
However, after navigating through my webapplication (which uses JPA (Hibernate)), I could only see a bunch of the following SQL statements:

EXEC sp_execute 6, 8
EXEC sp_execute 7, 8
EXEC sp_execute 4, 8

Hibernate is running a prepared query. To get the actual SQL query, you can run the following query (you will still have to look for the query, but, it's getting you a lot closer then sp_execute :-)):

SELECT        SQLTEXT.text, STATS.last_execution_time
FROM          sys.dm_exec_query_stats STATS
CROSS APPLY   sys.dm_exec_sql_text(STATS.sql_handle) AS SQLTEXT
WHERE         STATS.last_execution_time > GETDATE()-1
ORDER BY      STATS.last_execution_time DESC

By tweaking the WHERE clause, you can easily retrieve the quer(y)(ies) you are looking for :-)!

Cron entries removed after Synology DS213 reboot

Submitted by Jochus on Sat, 23/03/2013 - 13:45 | Posted in: Linux
Posted in

Yesterday, I came to the conclusion all my cron entries were removed (for the second time!) in my /etc/crontab file on my Synology DS213 NAS server.

I noticed the cron entries were removed after a system reboot. I figured out Synology has some problems with cron entries having columns separated with spaces (not tabs). All entries including spaces are removed on system startup.

Updating my crontab by putting tabs (\t) between the columns, fixed the problem.

Hiding "Spam" (or "Ongewenste e-mail") label in Gmail (automatically created by Outlook 2010)

Submitted by Jochus on Sat, 16/03/2013 - 18:48 | Posted in: Windows
Posted in

On my Windows laptop, I'm using Outlook 2010 to fetch my Gmail account (IMAP). Gmail has its own spam folder + spam filter, and I configured Outlook to use the Gmail spam filter.

Nevertheless, Outlook always creates a second spam folder (in Dutch called: Ongewenste e-mail), which makes it complicated on other clients (or webclient) to know which one is the correct label.
I just learned you can hide labels in your webclient and/or IMAP clients by logging in into Gmail webaccount > Settings > Labels . I also marked some other labels to be hidden as well.

Importing a large SQL file in Microsoft SQL server 2008

Submitted by Jochus on Wed, 13/03/2013 - 23:17 | Posted in: Database
Posted in

  • Go to: Start -> Run -> Type cmd and press enter
  • Once the command line is on screen tell SQLCMD to import your database by doing something like this:
    sqlcmd -S [server instance name] -d [database name] -i [filename you want to import]
  • If you're not sure about the server instance name; simply open up SQL Server Management Studio and on the login screen take a note of the Server Name textbox as this is the value you need to use as the server instance name.
  • If you are trying to enter a lot of INSERT statements, don't forget to flush while inserting using the GO command (for example, after each 100 rows).

How to cleanup InnoDB storage

Submitted by Jochus on Mon, 11/03/2013 - 21:33 | Posted in: Database
Posted in


After deleting some tables/databases on my MySQL server, I noticed the ibdata1 file is never shrinking. After almost a year, my MySQL ibdata1 file became really too large.
More information on this issue: http://bugs.mysql.com/bug.php?id=1341.


  • Dump (e.g., with mysqldump) all databases into a .sql text file
    $ mysqldump -u root -p --all-databases > bigdump.sql
  • Drop all databases (except for mysql and information_schema)
  • Login to mysql and run 'SET GLOBAL innodb_fast_shutdown = 0;' (This will completely flush all remaining transactional changes from ib_logfile0 and ib_logfile1)
  • Shutdown MySQL
  • Add the following lines to /etc/my.cnf:
  • Delete ibdata* and ib_logfile*
  • Start MySQL
  • Import databases
    $ mysql -u root -p < bigdump.sql

How to get the data directory of MySQL

Submitted by Jochus on Thu, 07/03/2013 - 19:30 | Posted in: Database
Posted in

I manually installed MySQL on my Macbook Pro, but I didn't know where MySQL stores its data by default (it's not defined in /etc/my.cnf). You can ask this to MySQL using the following query:


This will result in something like this:

| Variable_name | VALUE                |
| datadir       | /var/lib/mysql/DATA/ |
1 ROW IN SET (0.00 sec)

How good is my wifi signal?

Submitted by Jochus on Wed, 06/03/2013 - 20:30 | Posted in: Mac
Posted in

While holding down the ⌥ key when clicking on the wifi icon, you can learn more about the strength of the current wifi connection.


RSSI or Received Signal Strength Indication can go from 0 to -100. Generally the higher (closer to 0) the better, and the closer to -100 the worse. In telecommunications, RSSI is a measurement of the power present in a received radio signal (cf. Wikipedia).

Transmit Rate

The number to pay much more attention to is the Transmit Rate. This value is the rate of which information is processed by a transmission facility. The transmit rate will drop if you have too much noise or interference or if you are too far away from the base station.

For reference:

0   - No connection
6   - Half 802.11b
11  - 802.11b
54  - 802.11g
130 - 802.11n on 2.4 Ghz
300 - 802.11n on 5.0 Ghz