SQL Server/T-SQL

IANADBA2

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!

posted @ Tuesday, May 25, 2004 9:30 AM | Feedback (15)

Dealing With Stubborn Sql Server Log Files

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.

posted @ Monday, May 24, 2004 2:22 PM | Feedback (27)

IANADBA

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).

posted @ Monday, May 24, 2004 6:57 AM | Feedback (25)