
IF EXISTS
(
    SELECT *
    FROM sys.views
    WHERE object_id = OBJECT_ID(N'[dbo].[V_GLB_LAYOUT_FILIPETA_CARGA_TENTACLE]')
)
    DROP VIEW [dbo].[V_GLB_LAYOUT_FILIPETA_CARGA_TENTACLE];
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

--- SELECT * FROM V_GLB_LAYOUT_FILIPETA_CARGA_TENTACLE

CREATE VIEW [dbo].[V_GLB_LAYOUT_FILIPETA_CARGA_TENTACLE]
AS
SELECT
	CD_EMP
	,CD_FILIPETA
	,DS_FILIPETA
	,Campo1Encode AS CABECALHO
	,Campo2Encode AS RODAPE

from GLB_LAYOUT_FILIPETA
	cross apply (select CABECALHO '*' for xml path('')) T (Campo1Encode)
	cross apply (select RODAPE '*' for xml path('')) Tt (Campo2Encode)

WHERE GLB_LAYOUT_FILIPETA.CD_EMP = 1
GO

