Posts Tagged ‘tips’

Find most expensive queries in Microsoft SQL server

A colleague of mine found this little gem of a query (sorry, don’t know the original author). It finds the 20 most expensive queries executed on a SQL server instance, sorted by execution time. CPU load is also returned by the query. Here it is: SELECT TOP 20 qs.sql_handle, qs.execution_count, qs.total_worker_time AS Total_CPU, total_CPU_inSeconds = –Converted from microseconds qs.total_worker_time/1000000, average_CPU_inSeconds = –Converted from microseconds (qs.total_worker_time/1000000)/ qs.execution_count, [...]

More »

How to: Check if a Microsoft SQL-server database exists?

Here’s an easy, single line statement to check if a database exists in the current SQL-server instance: IF db_id(’db_name’) IS NOT NULL

More »

Compute hash of a file

Computing the hash value of a file is quite strait forward. I use the routine below. It opens the file, specifies the hash-algorithm to use and returns the hash of the file. If you rather use MD5 hashes, just change hashAlgorithm into MD5CryptoServiceProvider. Public Function ComputeFileHash(ByVal fileName As String) As String   Dim hashAlgorithm As [...]

More »

Icon Finder, the Google for icons

Here’s a very useful tool: http://www.iconfinder.net/ It allows you to search for icon, and it returns a lot of high quality images. Recommended!

More »

How to: Get the name of the running SQL-server instance

Here’s a script to retrieve the name of the currently running SQL Server instance: SELECT @@SERVERNAME AS ‘ServerName’ Resultset: ServerName ————————— DEV-SQL (1 row(s) affected)

More »

SQL-server: Get current database name

It can sometimes be handy to know in which database you are working. To get the name of the current database you can use a simple script: SELECT DB_NAME() AS DataBaseName Resultset: DatabaseName ———————— NorthWind (1 row(s) affected)

More »

Am I running as a 32 or 64-bit application?

Here’s an easy way to determine if a .NET application is running as either 32 or 64-bit  application. VB Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)   If IntPtr.Size = 8 Then     Response.Write("64-bit")   ElseIf IntPtr.Size = 4 Then     Response.Write("32-bit")   End If End Sub C# protected void [...]

More »

1,000 free icons

As a developer you’re probably familiar with the FamFamFam icon collection. It has certainly served me well over the years. But even though FamFamFam is great, there’s always room for improvement. That’s why you should check out the new FatCow collection, comprised of no less than 1,000 icons in both 16×16 and 32×32 high quality [...]

More »

Error message 401.2.: Unauthorized: Logon failed due to server configuration. (IIS7)

After installing Windows 7 my ASP.NET application displayed an Access is deniederror. The complete error message was: Error message 401.2.: Unauthorized: Logon failed due to server configuration.  Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server.  Contact the Web [...]

More »

HTTP Redirect using htaccess

To redirect all incoming traffic to a new site and send an http status code indicating that the content has moved permanently, use the following snippet in your .htaccess file:  RedirectMatch 301 ^(.*)$ http://www.mynewsite.com/ The 301 code is the status for permantly moved content. The regex ^(.*)$ matches all urls and finally http://www.mynewsite.com/ specifies where visitors must [...]

More »

7 signs your UI was created by a programmer

Are you a programmer? Then you might to read these 7 signs your UI was created by a programmer. No more excuses next time!

More »

Project name generator

Having trouble coming up with a suitable project name? Try this project name generator and you can get back to work. Here are some examples: Tidy Firecracker Rainbow Uranium Severe Tungsten Nocturnal Temple

More »

Select column names from a Microsoft SQL-Server table

I’ve posted a snippet before that allows you to select a list of tables (or views, stored procedures, etc) from a SQL-Server database. It would be only logical to also have a snippet that allows you to select the columns in the table you’re interested in. The following piece of SQL code does just that. [...]

More »

Easily create favicons

Helpful link to create favicons from your favourite image online: http://tools.dynamicdrive.com/favicon/

More »

HttpContext.Current.Request.UserHostAddress returns ::1

One would expect HttpContext.Current.Request.UserHostAddress to return the IP address of the client computer. On my developement machine this would be 127.0.0.1. The application I’m working on acts on this IP address, so it is fital to get the correct address. Since I’ve moved to Windows Server 2008 x64 on my laptop, I got ::1 as a [...]

More »