Result for the code


#1

given 2 tables created and populated as follows:

CREATE TABLE dbo.envelope(id int, user_id int);
CREATE TABLE dbo.docs(idnum int, pageseq int, doctext varchar(100));

INSERT INTO dbo.envelope VALUES
(1,1),
(2,2),
(3,3);

INSERT INTO dbo.docs(idnum,pageseq) VALUES
(1,5),
(2,6),
(null,0);

what will the result be for the following:

UPDATE docs SET doctext=pageseq FROM docs INNER JOIN envelope ON envelope.id=docs.idnum
WHERE EXISTS (
SELECT 1 FROM dbo.docs
WHERE id=envelope.id
);


#2

the output as follows:
idnum pageseq doctext
1 5 5
2 6 6
null 0 null
in exist clause id is not coloumn of docs table it refers to itself
and frrom that inner join 3 row of idnum = doctext


#3

Can you explain more about it ?