Author |
Topic |
ann
Posting Yak Master
220 Posts |
Posted - 2006-10-19 : 10:36:33
|
How can I add the current date into this sp (I want to add the current date into the Processed Table during the insert):insert into Processed(AcctNum, AcctPrevious, CardNum, CaseNumber, AvailBalance,Comments)select AcctNum, AcctPrevious, CardNum, CaseNumber, AvailBalance,Comments from tempCompthanks |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-19 : 10:38:29
|
To obtain current dateuse getdate() for current date & timeif you only want the dateuse dateadd(day, datediff(day, 0, getdate()), 0) KH |
 |
|
ann
Posting Yak Master
220 Posts |
Posted - 2006-10-19 : 10:53:49
|
So I would do something like this?:insert into Processed(AcctNum, AcctPrevious, CardNum, CaseNumber,AvailBalance,Comments, GetDate())select AcctNum, AcctPrevious, CardNum, CaseNumber,AvailBalance,Comments from tempComp |
 |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-10-19 : 11:11:28
|
No, you need a date processed column in the table you're inserting into, create a new column using the datetime or smalldatetime data type, then insert like thisinsert into Processed(AcctNum, AcctPrevious, CardNum, CaseNumber,AvailBalance,Comments, DateProcessed)select AcctNum, AcctPrevious, CardNum, CaseNumber,AvailBalance,Comments, getdate()from tempComp |
 |
|
ann
Posting Yak Master
220 Posts |
Posted - 2006-10-19 : 11:11:36
|
ok, so that doesn't work, so I tried this, but it doesn't work either:Declare @now datetimeset @now = GetDate()insert into Processed(AcctNum, AcctPrevious, CardNum, CaseNumber,AvailBalance,Comments, @now)select AcctNum, AcctPrevious, CardNum, CaseNumber,AvailBalance,Comments from tempCompbut I get: Incorrect syntax near '@now'does anyone know what\how I should do this? |
 |
|
ann
Posting Yak Master
220 Posts |
Posted - 2006-10-19 : 11:13:53
|
snSQL - I posted my reply before seeing yours - I did yours and it works perfect.Thank you for taking the time to help, I really appreciate it |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-21 : 07:39:36
|
or you can define that column to have GetDate() as default valueMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|