Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --with Diff as (
- -- select b1.fid as b1fid, b2.fid as b2fid
- -- 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
- -- where b1.fid is null or b2.fid is null
- --)
- --select b1fid as fid from Diff where b1fid is not null union select b2fid from Diff where b2fid is not null--13
- --select c1.*
- --from Chess as c1, Chess as c2
- --where c2.ftype = 'king' and
- -- c2.color = 'w' and
- -- abs(ascii(c1.x) - ascii(c2.x)) + abs(c1.y - c2.y) = (
- -- select min(abs(ascii(c1.x) - ascii(c2.x)) + abs(c1.y - c2.y))
- -- from Chess as c1, Chess as c2
- -- where not (c1.ftype = 'king' and c1.color = 'w') and
- -- c2.ftype = 'king' and
- -- c2.color = 'w'
- -- )--15
- --with ChessmenCount as (
- -- select ftype, color, count(ftype) as cnt from Chess group by ftype, color
- --)
- --select * from ChessmenCount where cnt >= 2--9'
- --USE [Zaytsev]
- --DROP PROCEDURE [dbo].[makeStep]
- --exec makeStep 'e', 1, 'd', 7
- --select * from Chess where 1=1
- --create procedure makeStep @fromx char, @fromy int, @tox char, @toy int as
- --if (select count(*) from Chess where x = @fromx and y = @fromy) = 1
- --begin
- -- if (select count(*) from Chess where x = @tox and y = @toy and color != (select color from Chess where x = @fromx and y = @fromy)) = 1
- -- begin
- -- declare @fid int
- -- set @fid = (select fid from Chess where x = @fromx and y = @fromy)
- -- delete from Chessboard where x = @tox and y = @toy
- -- update Chessboard set x = @tox, y = @toy where x = @fromx and y = @fromy
- -- end
- -- else if (select count(*) from Chess where x = @tox and y = @toy) = 0
- -- begin
- -- update Chessboard set x = @tox, y = @toy where x = @fromx and y = @fromy
- -- end
- -- else
- -- select 'Figure in ' + CAST(@tox as varchar) + ' ' + cast(@toy as varchar) + ' has the same color'
- --end
- --else
- -- select 'No figure in ' + cast(@fromx as varchar) + ' ' + cast(@fromy as varchar)--procedure task
- --create table StepsLog
- create trigger logStep
- on Chessboard
- after update as
- begin
- declare @fid int
- select @fid = inserted.fid from inserted
- insert into StepsLog
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement