SQL Server/T-SQL
Luciano Evaristo passes along a cool tip on how to get an average from a datetime field:
To workaround this, just change the SQL statement to SELECT CAST(AVG(CAST(MyTable.MyDateTimeField AS float)) AS datetime) FROM MyTable and things will work properly.
Cool tip!
Normally when you backup a database the log files are automatically truncated, however recently we had a development database that had racked up a 9GB log file! Despite nightly backup's the log file wouldn't clear.In order to shrink it down to a manageable size I ran the following commands from Query Analyzer:
BACKUP LOG DBName WITH TRUNCATE_ONLYGODBCC SHRINKFILE(LogFileName,SizeInMB) GO
Now all I have to do is figure out why it get so large in the first place.
I am not a dba, which is probably why I found this page on Dynamic SQL eye-opening and informative. If you are not a fully qualified dba, but find yourself writing stored procedures, it's a must read (or a re-read if you have already seen it).