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.
| Author |
Topic |
|
vbArch
Starting Member
5 Posts |
Posted - 2011-06-21 : 11:36:17
|
| I have added a field for Daylogged as Date, I have a field called DateLogged as datetime. I have updated all of the Daylogged fields by casting the Datelogged as Date field. I am having trouble setting a default value for the Daylogged field to equal the datelogged field. I have tried cast(datelogged as date) to no avail. Any suggestions would be appreciated. Thanks |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-06-21 : 11:54:39
|
| trigger?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-06-21 : 12:01:18
|
A default constraint can be applied to a column to give it a default value when a row is created. The default value is generally either a literal value, such as a specific number or string, or a reference to a function.create table webfred(id int identity(1,1), Daylogged Date default getdate(), Datelogged datetime)insert webfred(Datelogged) select getdate()select * from webfred No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
vbArch
Starting Member
5 Posts |
Posted - 2011-06-21 : 13:57:52
|
| A clarification is needed on my original post: The datelogged field is required and always has the time associated with it, the purpose for the daylogged field is to provide a means of indexing by day as opposed to datetime to improve performance, it is almost a calculated field. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-06-21 : 14:00:40
|
| Why can't it be made a calculated field? |
 |
|
|
|
|
|