To delete a the library and all parent libraries, assuming that the foreign key is a self-reference, you can do
WITH LibAncestors(libraryID, parentID, level) AS
(
SELECT libraryID, libraryID, 0
FROM Library
UNION ALL
SELECT a.libraryID, b.libraryParentID, a.level+1
FROM LibAncestors AS a INNER JOIN Library b
ON b.libraryID = a.parentID
)
DELETE FROM Library
WHERE libraryID IN
(SELECT LibraryParentID FROM LibAncestors WHERE LibraryID=?)
Here ? is the placeholder for your LibraryID to delete, and it's parent, and it's parent and so on.
The CTE returns a libraryID in the first column, and all ancestors (including the library itself) in the second column.
The 3rd column is how far away the parent is from the child. 0 is for the child itself, 1 for it's parent, 2 for it's grandparent and so on. If you don't want to delete all parents, you can specify a restriction in the WHERE clause. For example, to delete the child and just it's immediate parent (as specified in the question)
DELETE FROM Library
WHERE libraryID IN
(SELECT LibraryParentID FROM LibAncestors WHERE LibraryID=? AND level<=1)
I don't know if this will work with foreign keys defined from libraryID to libraryParentID. But you can disable key checking and re-enable it again by using
ALTER TABLE Library NOCHECK CONSTRAINT ALL
DELETE FROM Library ....
ALTER TABLE Library CHECK CONSTRAINT ALL