
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

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

from GLB_LAYOUT_FILIPETA
	cross apply (select CABECALHO '*' for xml path('')) T1 (Campo1Encode)
	cross apply (select RODAPE '*' for xml path('')) T2 (Campo2Encode)
	cross apply (select MSG_MK '*' for xml path('')) T3 (Campo3Encode)
WHERE GLB_LAYOUT_FILIPETA.CD_EMP = 1

