Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Date: Auto Data type

Author  Topic 

ldrenning
Starting Member

23 Posts

Posted - 2006-05-29 : 17:12:50
I am really new to this. Is there a way to set up a data type in SQL Server to automatically write the current date to a column? Instead of sending it from the page, the DB just writes the date to the column ...

Any guidance would be great!

-L

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2006-05-29 : 18:30:46
You can use a default value of getdate() or getutcdate() in your column.

create table #test(col1 char(3) not null primary key, thisisnow datetime not null default(getdate()))
insert #test(col1) values('abc')
select * from #test

rockmoose
Go to Top of Page
   

- Advertisement -