I am trying to insert more than one row in a table which uses the select statement as a sub query. It works fine when I insert only one row but gives an error when I try to insert more than one row.
INSERT INTO sysdba.ACTIVITY ([ACTIVITYID], [USERID], [CONTACTID])
(SELECT top 1
(SELECT CAST(MAX(ACTIVITYID) AS INT)
FROM sysdba.ACTIVITY) +
ROW_NUMBER() OVER (ORDER BY ENTITYID),
'admin',
[ENTITYID]
FROM
sysdba.CAMPAIGNTARGET
WHERE
CAMPAIGNID = 'Q6UJ9A00056A')
The error I get is:
Conversion failed when converting the varchar value 'CALENDAR' to data type int.