středa 9. listopadu 2016

Select Insert Into table


SQL
INSERT INTO dbo.[Company2CompanyTypes] ([CompanyRefId], [CompanyTypesRefId])
SELECT ANU.CompanyId, 2 AS CompanyTypeId FROM AspNetUsers ANU
INNER JOIN Company C ON (ANU.CompanyId = C.Id)
UNION
SELECT ANU.CompanyId, 3 AS CompanyTypeId FROM AspNetUsers ANU
INNER JOIN Company C ON (ANU.CompanyId = C.Id)

Zdroj:
http://www.w3schools.com/sql/sql_insert_into_select.asp

Žádné komentáře:

Okomentovat