Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. 'select * from o2o.dbo.sth'
  2.  
  3. use hxo2o
  4. go
  5. begin
  6. declare @last_sync_date_updater nvarchar(2000)
  7. declare @tb_name nvarchar(200)
  8. declare tb_name_cur cursor for
  9. select table_name from dbo.o2o_tables
  10.  
  11. open tb_name_cur
  12. fetch next from tb_name_cur into @tb_name
  13.  
  14. while @@fetch_status = 0
  15. begin
  16. set @last_sync_date_updater =
  17. 'update dbo.o2o_tables set table_last_sync_date = (select '
  18. + case
  19. when @tb_name = 'trace_user_actions' then 'max(operation_date_time)'
  20. else ' dbo.InlineMax(max(create_time), max(update_time)) ' end
  21. + 'from dbo.' + @tb_name + ')'
  22.  
  23. exec (@last_sync_date_updater)
  24.  
  25. fetch next from tb_name_cur into
  26. @tb_name
  27. end
  28. close tb_name_cur
  29. deallocate tb_name_cur
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement