Hi Could any one please help me while creating a view in SQL server toad I'm getting below error.Thanks in Advanced.
USE [database];
GO
SET ANSI_NULLS ON;
GO
SET QUOTED_IDENTIFIER ON;
GO
CREATE VIEW [dbo].[GCRM_CONTRACT_ENTITLEMENT] ("objid","CONTRACT__TITLE")
AS
(with mycte as (
SELECT table1.Column1 as objid,
table1.Column2 CONTRACT__TITLE
FROM table1
WHERE
(
(table1.struct_type = 0)
)
)
SELECT Stuff(( SELECT ',' + cast(CONTRACT__TITLE as varchar(2000))
FROM mycte t2
WHERE t2.[objid] = t1.[objid]
FOR XML PATH(''), TYPE).value('.', 'varchar(max)'),1,1,'') AS [AVILABLE_ENTITLEMENT]
FROM mycte t1
GROUP BY t1.[objid]
);
GO
Error:- SQL Server Database Error: Incorrect syntax near the keyword 'with'.
Viewdoes not accept parametersCREATE VIEW [dbo].[GCRM_CONTRACT_ENTITLEMENT] ("objid","CONTRACT__TITLE")in a view this is not allowed("objid","CONTRACT__TITLE");WITH cte as (SELECT ... )