I have a table in database called user which has following entries.
Userid FirstName LastName
1 fa la
2 fb lb
3 fc lc
and another table userform
Userformid Userid Form Code modifieddate Isclosed IsForm
1 1 ff cc somedate 0 0
2 1 gg rr somedate 0 0
3 1 bb bb somedate 0 0
4 2 ss aa somedate 0 0
5 2 qq sa somedate 0 0
6 3 ws xc somedate 0 0
Now i have to insert new record for every userid in userform table and only Form and Code column should get copied in inserted row from userform table only by latest modifieddate ( something like:- order by modifieddate desc.)
Output should be in userform table :
Userformid Userid Form Code modifieddate Isclosed IsForm
1 1 ff cc somedate 0 0
2 1 gg rr somedate 0 0
3 1 bb bb somedate 0 0
4 2 ss aa somedate 0 0
5 2 qq sa somedate 0 0
6 3 ws xc somedate 0 0
newly added row
7 1 bb bb newdate 0 0
8 2 qq sa newdate 0 0
9 3 ws xc newdate 0 0
There are 6000 record in user table and userform table.
How can we achieve this using bulk insert feature OR using any other technics in sql server 2005.I don't want to use CURSOR.