After executing following query i got exception 
 
 
"Msg 319, Level 15, State 1, Line 60
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.
Msg 8180, Level 16, State 1, Procedure sp_describe_parameter_encryption, Line 1 [Batch Start Line 6]
Statement(s) could not be prepared.
An error occurred while executing batch. Error message is: Internal error. Metadata for parameter '@p07290f7aba6643e6897a5d06e06fe5e3' in statement or procedure 'DECLARE @page AS INT = @p07290f7aba6643e6897a5d06e06fe5e3, @size AS INT = @pd9ea99d7d0224318b34dbaa90756f1a9, @search_query AS VARCHAR (50) = @pb5d6ad831f664539a2f4b59bb8cad7d8, @genericSearch AS INT = @pf398ac01c183480eb9d482335baa3eb3, @zone_id AS INT = NULL, @user_id AS INT = @p8504e13806f24366a628538a2f1c8745;" 
 
 
-   
 -   
 -   
 -   
 - DECLARE  
 - @page INT=-1, @size INT=-1, @search_query VARCHAR (50)= '65A', @genericSearch INT=1, @zone_id INT=NULL, @user_id INT=3  
 - BEGIN  
 - DECLARE @role_code AS VARCHAR (50);  
 - DECLARE @venue_id AS INT;  
 - DECLARE @gender AS VARCHAR (50);  
 - DECLARE @isLocationAssigned AS INT;  
 - IF @page = -1  
 - SET @page = 1;  
 - IF @size = -1  
 - SET @size = (SELECT IIF (COUNT(1) > 0, COUNT(1), 1)  
 - FROM ar_location  
 - WHERE is_active = 1);  
 - SELECT @role_code = ur.role_code,  
 - @gender = u.gender  
 - FROM users AS u  
 - INNER JOIN  
 - user_role AS ur  
 - ON ur.user_role_id = u.UserRole  
 - WHERE u.UserId = @user_id  
 - AND ur.is_active = 1;  
 - SET @venue_id = (SELECT TOP 1 venue_id  
 - FROM rel_user_venue  
 - WHERE user_id = @user_id);  
 - DECLARE @shift_staff_schedule AS BIT, @location_user_assignment AS BIT, @either_one_or_these AS BIT, @on_duty AS BIT, @location_staff_gender AS BIT;  
 - SELECT TOP 1 @shift_staff_schedule = uar.shift_staff_schedule,  
 - @location_user_assignment = uar.location_user_assignment,  
 - @either_one_or_these = uar.either_one_or_these,  
 - @on_duty = uar.on_duty,  
 - @location_staff_gender = uar.location_staff_gender  
 - FROM user_assignment_rule AS uar  
 - INNER JOIN  
 - venue AS v  
 - ON v.venue_id = uar.venue_id  
 - WHERE v.venue_id = @venue_id  
 - AND uar.is_active = 1;  
 - IF @either_one_or_these = 1  
 - BEGIN  
 - SET @shift_staff_schedule = 1;  
 - SET @location_user_assignment = 1;  
 - END  
 - IF @role_code <> 'staff'  
 - BEGIN  
 - SET @location_staff_gender = 0;  
 - END  
 - SET @isLocationAssigned = 0;  
 - IF @role_code = 'staff'  
 - OR @role_code = 'supervisor'  
 - BEGIN  
 - SELECT @isLocationAssigned = COUNT(1)  
 - FROM user_location_assignment  
 - WHERE user_id = @user_id;  
 - END;  
 - WITH restroomList AS  
 - (  
 - SELECT DISTINCT CASE WHEN wt.assigned_to > 0 THEN 0 ELSE 1 END AS create_cleaning_alert_btn,  
 - l.location_id,  
 - l.location_name,  
 - ird.infax_restroom_details_id,  
 - ird.camera_threshold,  
 - ird.camera_last_reset,  
 - ird.last_visited,  
 - ird.camera_last_warn_notify,  
 - ird.camera_last_max_notify,  
 - ird.camera_warn_precent,  
 - ird.current_day_count,  
 - ird.count_since_reset,  
 - ird.feedback,  
 - ird.location_group_name,  
 - ird.restroom_name,  
 - ird.restroom_type,  
 - ird.restroom_description,  
 - l.longitude,  
 - l.latitude,  
 - l.altitude,  
 - b.building_id,  
 - b.building_name,  
 - l.created_by,  
 - l.created_date,  
 - l.modified_by,  
 - l.modified_date,  
 - v.venue_id,  
 - v.venue_name,  
 - z.zone_id,  
 - z.zone_name,  
 - l.location_type,  
 - dbo.fnGetLocationLastCleanedDate(l.location_id) AS last_cleaned_date,  
 - dbo.fnGetLocationLastCleanedAssigneeName(l.location_id) AS assignee_name,  
 -   
 - blue.created_at AS opened_date,  
 - CASE WHEN vw.location_id > 0 THEN 1 ELSE 0 END AS is_unassigned,  
 -   
 - ROW_NUMBER() OVER (PARTITION BY l.location_id ORDER BY l.location_id DESC) AS loc_num  
 - FROM ar_location AS l  
 - INNER JOIN  
 - zone AS z  
 - ON z.zone_id = l.zone_id  
 - AND z.is_active = 1  
 - AND l.is_active = 1  
 - INNER JOIN  
 - building AS b  
 - ON b.building_id = z.building_id  
 - AND b.is_active = 1  
 - INNER JOIN  
 - venue AS v  
 - ON v.venue_id = b.venue_id  
 - AND v.is_active = 1  
 - LEFT OUTER JOIN  
 - staff_schedule AS ss  
 - ON ss.user_id = @user_id  
 - AND ss.zone_id = z.zone_id  
 - AND ss.is_active = 1  
 - LEFT OUTER JOIN  
 - user_location_assignment AS ula  
 - ON ula.user_id = @user_id  
 - AND ula.is_active = 1  
 - AND ula.location_id = l.location_id  
 - LEFT OUTER JOIN  
 - (SELECT wt.*,  
 - ROW_NUMBER() OVER (PARTITION BY workorder_id ORDER BY workorder_transaction_id DESC) AS NUM  
 - FROM workorder_transaction AS wt) AS wt  
 - ON wt.assigned_to = @user_id  
 - AND NUM = 1  
 - AND (wt.status_id IN (SELECT status_id  
 - FROM workorder_status  
 - WHERE (status = 'Inprogress'  
 - OR status = 'Assigned'))  
 - AND @role_code = 'staff')  
 - LEFT OUTER JOIN  
 - vwLatestWOTransaction AS blue  
 - ON blue.location_id = l.location_id  
 - AND blue.rn = 1  
 - AND blue.status_id NOT IN (SELECT status_id  
 - FROM workorder_status  
 - WHERE (status = 'Close'  
 - OR status = 'Cancel'))  
 - LEFT OUTER JOIN  
 - (SELECT ird.*,  
 - ROW_NUMBER() OVER (PARTITION BY venue_id, restroom_name ORDER BY infax_restroom_details_id DESC) AS r_num  
 - FROM infax_restroom_details AS ird) AS ird  
 - ON ird.restroom_name = l.location_name  
 - AND ird.r_num = 1  
 - LEFT OUTER JOIN  
 - vwUnassignedLocations AS vw  
 - ON vw.location_id = l.location_id  
 - WHERE (@role_code = 'sysadmin'  
 - OR (@role_code = 'clientadmin'  
 - AND v.venue_id = @venue_id))  
 - OR ((@role_code <> 'sysadmin'  
 - OR @role_code <> 'clientadmin')  
 - AND v.venue_id = @venue_id  
 - AND (@location_staff_gender = 0  
 - OR (@location_staff_gender = 1  
 - AND (l.location_type = @gender  
 - OR l.location_type = 'B')))  
 - AND (@location_user_assignment = 0  
 - OR (@location_user_assignment = 1  
 - AND @either_one_or_these = 0  
 - AND ula.user_id IS NOT NULL)  
 - OR (@location_user_assignment = 1  
 - AND @either_one_or_these = 1  
 - AND (ula.user_id IS NOT NULL  
 - OR (@isLocationAssigned = 0  
 - AND ss.user_id IS NOT NULL))))  
 - AND (@shift_staff_schedule = 0  
 - OR ((@shift_staff_schedule = 1  
 - AND @either_one_or_these = 0  
 - AND ss.user_id IS NOT NULL)  
 - OR (@shift_staff_schedule = 1  
 - AND @either_one_or_these = 1  
 - AND (ula.user_id IS NOT NULL  
 - OR (@isLocationAssigned = 0  
 - AND ss.user_id IS NOT NULL))))))  
 -   
 - )  
 - SELECT *,Count(1) OVER () AS total_rows FROM restroomList  
 - WHERE loc_num=1 AND ((@genericSearch = 1  
 - AND ( location_name LIKE '%' + ISNULL(@search_query, location_name) + '%'  
 - OR venue_name LIKE '%' + ISNULL(@search_query, venue_name) + '%'  
 - OR building_name LIKE '%' + ISNULL(@search_query, building_name) + '%'  
 - OR zone_name LIKE '%' + ISNULL(@search_query, zone_name) + '%'))  
 - OR (@genericSearch <> 1  
 - AND ( location_name LIKE '%' + ISNULL(@search_query, location_name) + '%'  
 - OR venue_name LIKE '%' + ISNULL(@search_query, venue_name) + '%'  
 - OR building_name LIKE '%' + ISNULL(@search_query, building_name) + '%'  
 - OR zone_name LIKE '%' + ISNULL(@search_query, zone_name) + '%')))  
 - ORDER BY count_since_reset DESC  
 - OFFSET ((@page - 1) * @size) ROWS FETCH NEXT @size ROWS ONLY  
 - END