tsql - Can I select the data of a given row and column while executing a sql statement -


to clarify title, in select statement, in clause, need verify table on doing using select. in second select, have find secondary id. here have worked out far

declare @id int  --inserting values in temp table select    rn = row_number() on (order adt_trl_dt_tm),    * #temp dbo.evnt_hstry order adt_trl_dt_tm desc   --searching items deleted , have not been restored select * dbo.evnt_hstry hstry evnt_hstry_cd '3' , adt_trl_dt_tm   > (select adt_trl_dt_tm dbo.evnt_hstry evnt_id = evnt_id  drop table #temp 

to clarify code, evnt_id foreign key. primary key evnt_hstry_id. evnt_hstry_cd 3 means deleted. trying see if field adt_trl_dt_tm (lastest date modified) of row being read latest comparing adt_trl_dt_tm fields have same evnt_id.

the table doing select on table store history of events. when event has been added, modified, deleted , or restored.

sadly, cannot application statement being run in ssis.

overall, need compare adt_trl_dt_tm other adt_trl_dt_tm have same evnt_id , select latest.

can test data ?

select * dbo.evnt_hstry hstry evnt_hstry_cd '3' , not exists (select 1 evnt_hstry hstry.evnt_id = evnt_id , hstry.adt_trl_dt_tm > adt_trl_dt_tm) 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -