Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8386121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:50:51+00:00 2026-06-09T17:50:51+00:00

Create FUNCTION [dbo].[GetAllChildSpaces] ( @CustomSpaceId varchar(40), @Userid int ) RETURNS NVARCHAR(MAX) AS BEGIN DECLARE

  • 0
Create FUNCTION [dbo].[GetAllChildSpaces] 
(
    @CustomSpaceId varchar(40),
    @Userid int 
)
RETURNS NVARCHAR(MAX)
AS
BEGIN   
    DECLARE @Totalspace NVARCHAR(MAX)
    DECLARE  @tblTotalSpace table (CustomSpaceId NVARCHAR(40))

    WITH Hierachy (CustomSpaceId) AS 
     ( 
     SELECT  CustomSpaceId FROM  CV_CustomSpace e 
     UNION ALL 
     SELECT  e1.CustomSpaceId FROM  CV_CustomSpace e1 INNER JOIN Hierachy p  ON e1.ParentID = p.CustomSpaceId 
     ) 

  INSERT INTO @tblTotalSpace (CustomSpaceId)

  SET @Totalspace=( 
      SELECT STUFF((SELECT ',' + CAST(CustomSpaceId as varchar(50)) 
      FROM @tblTotalSpace FOR XML PATH('')) ,1,1,'') AS TotalSpaceID
  )

  DROP TABLE @tblTotalSpace

  return @Totalspace  
 END 

I’m getting an error:

Incorrect syntax near the keyword 'with'. If this statement is a
common table expression, an xmlnamespaces clause or a change tracking
context clause, the previous statement must be terminated with a
semicolon.

Can any one solve this issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:50:53+00:00Added an answer on June 9, 2026 at 5:50 pm

    Terminate the previous statement with a semicolon

    Create FUNCTION [dbo].[GetAllChildSpaces] ( @CustomSpaceId varchar(40), @Userid int ) RETURNS NVARCHAR(MAX) AS BEGIN
    DECLARE @Totalspace NVARCHAR(MAX) 
    DECLARE @tblTotalSpace table (CustomSpaceId NVARCHAR(40)); -- Here
    
    WITH Hierachy (CustomSpaceId) AS 
    ...
    

    For consistency and clarity, it doesn’t hurt to terminate all statements with a semicolon.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function: CREATE FUNCTION [dbo].[udf_StripHTML] (@HTMLText VARCHAR(MAX)) RETURNS VARCHAR(MAX) AS BEGIN DECLARE
So I have this working properly: CREATE FUNCTION dbo.GetLiveStream(@UserName NVARCHAR(MAX)) RETURNS TABLE AS RETURN
CREATE FUNCTION dbo.GetCustomers ( @ZIPCode VARCHAR(255) ) RETURNS TABLE AS BEGIN SELECT * dbo.GetCustomers
Consider the following tsql... create function dbo.wtfunc(@s varchar(50)) returns varchar(10) begin return left(@s, 2);
CREATE FUNCTION [dbo].[MSG_FilterAutoship] ( @ItemID VARCHAR(50) = NULL ) RETURNS @Autoship TABLE ( DistID
I have simplified my function to the following: create function [dbo].[UserSuperTeams](@ProjectId int) returns table
I have this script: CREATE FUNCTION dbo.CheckIfSFExists(@param1 INT, @param2 BIT = 1 ) RETURNS
I've used the following split function: CREATE FUNCTION dbo.Splitfn(@String varchar(8000), @Delimiter char(1)) returns @temptable
CREATE function [dbo].[fn_GetDateOnly](@dateWithTime datetime) returns datetime WITH SCHEMABINDING as begin return DATEADD(DAY, DATEDIFF(DAY, 0,
I have the following UDF. CREATE FUNCTION [dbo].[udf_GenerateVarcharTableFromStringList] (@list varchar(MAX), @delimiter char(1) = N',')

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.