Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --with Diff as (
  2. --  select b1.fid as b1fid, b2.fid as b2fid
  3. --  from Board_1 as b1 full join Board_2 as b2 on b1.fid = b2.fid and b1.x = b2.x and b1.y = b2.y
  4. --  where b1.fid is null or b2.fid is null
  5. --)
  6. --select b1fid as fid from Diff where b1fid is not null union select b2fid from Diff where b2fid is not null--13
  7. --select c1.*
  8. --from Chess as c1, Chess as c2
  9. --where c2.ftype = 'king' and
  10. --  c2.color = 'w' and
  11. --  abs(ascii(c1.x) - ascii(c2.x)) + abs(c1.y - c2.y) = (
  12. --      select min(abs(ascii(c1.x) - ascii(c2.x)) + abs(c1.y - c2.y))
  13. --      from Chess as c1, Chess as c2
  14. --      where not (c1.ftype = 'king' and c1.color = 'w') and
  15. --          c2.ftype = 'king' and
  16. --          c2.color = 'w'
  17. --      )--15
  18. --with ChessmenCount as (
  19. --  select ftype, color, count(ftype) as cnt from Chess group by ftype, color
  20. --)
  21. --select * from ChessmenCount where cnt >= 2--9'
  22.  
  23. --USE [Zaytsev]
  24. --DROP PROCEDURE [dbo].[makeStep]
  25.  
  26. --exec makeStep 'e', 1, 'd', 7
  27. --select * from Chess where 1=1
  28.  
  29. --create procedure makeStep @fromx char, @fromy int, @tox char, @toy int as
  30. --if (select count(*) from Chess where x = @fromx and y = @fromy) = 1
  31. --begin
  32. --  if (select count(*) from Chess where x = @tox and y = @toy and color != (select color from Chess where x = @fromx and y = @fromy)) = 1
  33. --  begin
  34. --      declare @fid int
  35. --      set @fid = (select fid from Chess where x = @fromx and y = @fromy)
  36. --      delete from Chessboard where x = @tox and y = @toy
  37. --      update Chessboard set x = @tox, y = @toy where x = @fromx and y = @fromy
  38. --  end
  39. --  else if (select count(*) from Chess where x = @tox and y = @toy) = 0
  40. --  begin
  41. --      update Chessboard set x = @tox, y = @toy where x = @fromx and y = @fromy
  42. --  end
  43. --  else
  44. --      select 'Figure in ' + CAST(@tox as varchar) + ' ' + cast(@toy as varchar) + ' has the same color'
  45. --end
  46. --else
  47. --  select 'No figure in ' + cast(@fromx as varchar) + ' ' + cast(@fromy as varchar)--procedure task
  48.  
  49. --create table StepsLog
  50.  
  51. create trigger logStep
  52. on Chessboard
  53. after update as
  54. begin
  55.     declare @fid int
  56.     select @fid = inserted.fid from inserted
  57.     insert into StepsLog
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement