Search  
Wednesday, January 07, 2009 ..:: Blogs ::.. Register  Login
 Moke Blog Minimize

    

 Moke Blog Minimize

    

 Time Stamp changes to your database table Minimize
Location: BlogsMoke Blog    
Posted by: Rick Mokros 5/21/2007 12:57:00 PM

Below is a snippet of SQL code that I use to add transaction-time columns to a database table.

a) when and who created a record

b) when and who updated a record

Snodgrass refers to a table with these columns as a transaction-time state table.

alter table [table1] add [CreateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_table1_CreateDate] DEFAULT (getdate())
alter table [table1] add [CreateUserId] [varchar] (20) NOT NULL CONSTRAINT [DF_table1_CreateUserId] DEFAULT (suser_sname())
alter table [table1] add [UpdateDate] [smalldatetime] NOT NULL CONSTRAINT [DF_table1_UpdateDate] DEFAULT (getdate())
alter table [table1] add [UpdateUserId] [varchar] (20) NOT NULL CONSTRAINT [DF_table1_UpdateUserId] DEFAULT (suser_sname())

Permalink |  Trackback

Comments (1)   Add Comment
Re: Time Stamp changes to your database table    By rmokros on 5/21/2007 4:55:50 PM
modified UserId fields to be type varchar rather than char


Your name:
Title:
Comment:
Add Comment   Cancel 

  

There are no categories in this blog.
Copyright 2006 by Moke's Information Technology, Inc.   Terms Of Use  Privacy Statement