Click here to Skip to main content
13,249,443 members (32,297 online)

Why following query gives error

k@ran asked:

Open original thread
declare @vc_opportunity_id varchar(100);
set @vc_opportunity_id = '';
declare @in_website_id int;
set @in_website_id = 0;
SELECT a.in_log_id, a.in_website_id, a.vc_opportunity_id, e.Name AS vc_opportunity_name, a.in_client_id, b.in_user_type_id, b.vc_first_name, b.vc_last_name, b.vc_email, d.vc_user_type, c.vc_website_domain_name, a.vc_old_stage_name, a.vc_new_stage_name, a.vc_old_procedure_of_interest__c, a.vc_new_procedure_of_interest__c, a.vc_old_service_of_interest__c,
a.vc_new_service_of_interest__c, CONVERT(VARCHAR(20), a.dt_old_date_of_consultation_c, 101) AS old_consultation_date, CONVERT(VARCHAR(20), a.dt_new_date_of_consultation_c, 101) AS new_consultation_date, a.vc_old_consultation_time_c, a.vc_new_consultation_time_c, CASE WHEN CONVERT(VARCHAR, a.dt_old_appointment_date__c, 101) = '01/01/1900' THEN NULL ELSE CONVERT(VARCHAR, a.dt_old_appointment_date__c, 101) END AS old_appointment_date,
CASE WHEN CONVERT(VARCHAR, a.dt_new_appointment_date__c, 101) = '01/01/1900' THEN NULL ELSE CONVERT(VARCHAR, a.dt_new_appointment_date__c, 101) END AS new_appointment_date, a.vc_old_appointment_window_start__c, a.vc_new_appointment_window_start__c, a.vc_old_appointment_window_end__c, a.vc_new_appointment_window_end__c,
CONVERT(VARCHAR(20), a.dt_log_created, 100) AS log_date FROM dbo.sf_opportunity_client_update_log a
INNER JOIN dbo.website_user b ON a.in_website_id = b.in_website_id AND a.in_user_type_id = b.in_user_type_id
INNER JOIN dbo.website c ON a.in_website_id = c.in_website_id AND c.bt_active = 1
INNER JOIN dbo.common_data_vw_website_user_type d ON a.in_user_type_id = d.in_key
INNER JOIN dbo.sf_opportunity e ON a.vc_opportunity_id = e.Id
WHERE
CASE
WHEN @in_website_id <> 0 THEN a.in_website_id = @in_website_id  ELSE  a.vc_opportunity_id LIKE @vc_opportunity_id + '%'
END = 1


It give Msg 102, Level 15, State 1, Line 15
Incorrect syntax near '='. inside where
Tags: SQL-Server (SQL-server-2005)

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy |
Web03 | 2.8.171114.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100