I have an insert statements for which I want to make 2 inserts. I have the following code:
INSERT INTO [dbo].[Licemb]
([Lic_Id],
[LicEmb_EmbTS],
[LicEmb_EmbOffset])
SELECT TOP 1
Lic_ID,
'00:00:00',
-7
FROM dbo.Lics
WHERE Org_ID = 2
ORDER BY NP_ID DESC
UNION ALL
SELECT TOP 1
Lic_ID,
'00:00:00',
-7
FROM dbo.Lics
WHERE Org_ID = 4
ORDER BY NP_ID DESC
however I keep getting syntax errors and I can't find a work around after searching for a while.
Error:
Incorrect syntax near the keyword 'UNION'.
How can I modify this code so that I can use a single statement to make 2 inserts with selects?
Any help would be much appreciated.