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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2007-01-18 : 08:39:16
|
| Brian writes "I need help inserting the "current" date and time into a table while creating a new row in an existing table. I want to write a dynamic bit of code that can be used over and over again on different days. Any thoughts?" |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-01-18 : 08:41:27
|
| Why don't you attach getdate() as default to the date column?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-18 : 09:35:23
|
| ALTER TABLE <YourTableNameHere>ADD <YourColumnNameHere> AS GETDATE() WITH VALUESPeter LarssonHelsingborg, Sweden |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-01-18 : 10:33:04
|
quote: Originally posted by Peso ALTER TABLE <YourTableNameHere>ADD <YourColumnNameHere> AS GETDATE() WITH VALUESPeter LarssonHelsingborg, Sweden
I think you meant DEFAULT, not AS:ALTER TABLE <YourTableNameHere>ADD <Your ColumnName> DATETIME NOT NULL DEFAULT (GETDATE()) WITH VALUES CODO ERGO SUM |
 |
|
|
allcaz
Starting Member
1 Post |
Posted - 2007-02-01 : 11:39:54
|
| What if you don't have rights to alter the table? Isn't there a hotkey you can use, or create, like Excel's CTRL+; ? Seems like this used to work in Enterprise Manager, but no longer works in SSMS. |
 |
|
|
|
|
|