Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

tsql - How to implement bulk insert feature in Sql Server 2005 -


i have table in database called user has following entries.

userid firstname lastname 1          fa      la 2          fb      lb 3          fc      lc 

and 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 have insert new record every userid in userform table , form , code column should copied in inserted row userform table latest modifieddate ( like:- order modifieddate desc.)

output should 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 6000 record in user table , userform table.

how can achieve using bulk insert feature or using other technics in sql server 2005.i don't want use cursor.

something this, making use of row_number should trick. try first without insert check results returns. if want, uncomment insert line , go ahead.

declare @newdate datetime set @newdate = getdate()  --insert userform (userid, form, code, modifieddate, isclosed, isform) select userid, form, code, @newdate, isclosed, isform (     select row_number() on (partition userid order modifieddate desc) rowno,          userid, form, code, isclosed, isform     userform  ) x rowno = 1 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -