Код, создающий и заполняющий таблицу Links
USE tempdb;
SET NOCOUNT ON;
GO
IF OBJECT_ID(?Links?) IS NOT NULL
DROP TABLE Links;
GO
CREATE TABLE Links
( src_pid int NOT NULL,
tgt_pid int NOT NULL,
PRIMARY KEY(src_pid, tgt_pid) );
GO
INSERT INTO Links(src_pid, tgt_pid) VALUES(1, 2);
INSERT INTO Links(src_pid, tgt_pid) VALUES(1, 3);
INSERT INTO Links(src_pid, tgt_pid) VALUES(1, 4);
INSERT INTO Links(src_pid, tgt_pid) VALUES(1, 7);
INSERT INTO Links(src_pid, tgt_pid) VALUES(2, 5);
INSERT INTO Links(src_pid, tgt_pid) VALUES(2, 6);
INSERT INTO Links(src_pid, tgt_pid) VALUES(4, 7);
INSERT INTO Links(src_pid, tgt_pid) VALUES(7, 8);
GO