0% found this document useful (0 votes)
24 views1 page

CourseType Cte Insert Into

This SQL query uses a common table expression to select distinct course type records from a source table, then inserts the distinct records into a destination table, removing any duplicate course type values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

CourseType Cte Insert Into

This SQL query uses a common table expression to select distinct course type records from a source table, then inserts the distinct records into a destination table, removing any duplicate course type values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

;WITH CTE (CourseTypeID,[CourseType]

,[Description]
,[OrderTag]
,[CourseType_fr]
,[MCIServiceID]
,[iCARE_ID]
,[IsReserved], DuplicateCount)
AS
(
SELECT CourseTypeID,[CourseType]
,[Description]
,[OrderTag]
,[CourseType_fr]
,[MCIServiceID]
,[iCARE_ID]
,[IsReserved],
ROW_NUMBER() OVER(PARTITION BY [CourseType] ORDER BY [CourseType]) AS
DuplicateCount
FROM tCourseType
) ,
up as (SELECT CourseTypeID,[CourseType]
,[Description]
,[OrderTag]
,[CourseType_fr]
,[MCIServiceID]
,[iCARE_ID]
,[IsReserved] from CTE Where DuplicateCount = 1 )

INSERT INTO [dbo].[tCourseTypes]


(CourseTypeID,[CourseType]
,[Description]
,[OrderTag]
,[CourseType_fr]
,[MCIServiceID]
,[iCARE_ID]
,[IsReserved])
SELECT * FROM up

select * from [dbo].[tCourseTypes]

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy