Click here to Skip to main content
15,886,104 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to update in insert time sql server 2008
Posted
Comments
pradiprenushe 6-Jan-15 1:46am    
not clear
King Fisher 6-Jan-15 1:49am    
What have you tried?
OriginalGriff 6-Jan-15 1:52am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
INSERT and UPDATE are very specific terms in SQL, and using them both in the same sentence doesn't make a lot of sense.
Try explaining in more detail exactly what you are trying to do, and what you have tried - and an example often helps us to visualise the problem.
Use the "Improve question" widget to edit your question and provide better information.

Use the time field - http://msdn.microsoft.com/en-IN/library/bb677243.aspx[^] to store time in the database.
 
Share this answer
 
Question is not Clear!..

I think you need to update table after Insert records in table.

so you need to use Triggers!..

here some Examples try this..

SQL
create table temp (id int primary key identity(1,1),Name varchar (10), test2 varchar(20),date datetime)
insert temp values ('SAM','English','')


SQL
create trigger tri_update on temp
for insert
as
declare @id int;
declare @date datetime;
set @date=GETDATE();

select @id=i.id from  inserted i;

update temp set date=@date where id=@id;


I think it hopes helpful!...
Here the Trriger update a inserted time into date filed

SQL
insert temp values ('JOHN','Maths','')

select * from temp
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900