user3392326
user3392326

Reputation: 1

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >=

I am trying to fetch the data in three tables by using their version columns.

HERE IS MY CODE:

INSERT INTO [dbo].tblCALPLA(ACCOUNT,DATASRC,VERSION)

SELECT ACCOUNT,DATASRC,VERSION FROM [dbo].TBLFACT
WHERE VERSION=(SELECT ID FROM [dbo].VERSION)

UNION

SELECT ACCOUNT,DATASRC,VERSION FROM [dbo].TBLFACT1
WHERE VERSION=(SELECT ID FROM [dbo].VERSION)

UNION

SELECT ACCOUNT,DATASRC,VERSION FROM [dbo].TBLFACT2
WHERE VERSION=(SELECT ID FROM [dbo].VERSION)

Upvotes: 0

Views: 313

Answers (1)

TechnoBrat
TechnoBrat

Reputation: 277

In all your WHERE conditions, instead of

WHERE Version = (SELECT ID ...)

make use of

WHERE Version IN (SELECT ID...)

Upvotes: 1

Related Questions