Thursday, March 4, 2010

Moving Average in T-SQL

I don't have time to go through this now, but think I am will most likely like to know this sometime:  http://www.sqlservercentral.com/articles/Moving+Average/69389/

Post code here

Column Exists before creating

I do not know why, but I have trouble remembering how to check if a SQL Server Column exists before trying to add it.  Here it is:

IF NOT EXISTS (select * from syscolumns where id=object_id('[table_name]') and name='[column_name]')
    alter table [table_name] add [column_name] [column_definition>]