SQL Server write to EventLog

Getting debug information from a complex stored procedure can sometimes be a challenge in sql server. Do you write to a log table or return the information as part of the query response? Why not use the event log?

Turns out writing to the event log from within a stored procedure is really easy:
DECLARE @@MESSAGE varchar(255)
set @@MESSAGE = 'executing sub query XXX'
EXEC xp_logevent 60000, @@MESSAGE, informational

Determine the file size of a database using t-sql


Determine the file size of a database using t-sql

In SQL Server there are a number of ways to determine how large a database is. Right clicking and selecting properties > files in management studio for example is probably the easiest. However if you do not have very high permissions on the database you are interested in this t-sql may be what you need. 

This script requires the least permissions of all the different methods I could find and is fairly simple which is a bonus.

select a.FILEID,
      [FILE_SIZE_MB] convert(decimal(12,2),round(a.size/128.000,2)),
      [SPACE_USED_MB] convert(decimal(12,2),round(fileproperty(a.name,'SpaceUsed')/128.000,2)),
      [FREE_SPACE_MB] convert(decimal(12,2),round((a.size-fileproperty(a.name,'SpaceUsed'))/128.000,2)),
      NAME = left(a.NAME,15),
      FILENAME = left(a.FILENAME,30)
from dbo.sysfiles a

Tested in SQL Server 2005+ 

Font made of dashes


If you are looking for a way to make letters in ms word etc be made up of dots or dashes then you will need a to download a special font. A good example for why you may want this is to help kids learn to write letters by tracing.

Here is one that I have as some success with. Its free and just works: http://desktoppub.about.com/od/lessonplans/ig/Free-Print---Cursive-Fonts/Print-Clearly-Dashed.htm

The good thing about a font rather than a ready made worksheet is that you can make it however you like for example you can make a page with the childs name on it etc.