为什么以下查询会出错 [英] Why following query gives error

查看:63
本文介绍了为什么以下查询会出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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





给予Msg 102,15级,状态1,第15行

''=''附近的语法不正确。在哪里

推荐答案

您好,



请查看以下链接



http:// p2p。 wrox.com/sql-server-2000/832-case-where-clause.html [ ^ ]

http://www.sqlservercentral.com/Forums/Topic1213442-338-1.aspx#bm1215738 [ ^ ]

http://weblogs.sqlteam.com/jeffs/archive/2003/11/14/513.aspx [ ^ ]

http://shivasoft.in/blog/sql/case-statement-in-where-clause-sql- server-conditional-where-clause / [ ^ ]
Hi,

please check the below links

http://p2p.wrox.com/sql-server-2000/832-case-where-clause.html[^]
http://www.sqlservercentral.com/Forums/Topic1213442-338-1.aspx#bm1215738[^]
http://weblogs.sqlteam.com/jeffs/archive/2003/11/14/513.aspx[^]
http://shivasoft.in/blog/sql/case-statement-in-where-clause-sql-server-conditional-where-clause/[^]


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



End = 1抛出此错误。删除它,然后重试。


End = 1 is throwing this error. Remove this and try again.


这篇关于为什么以下查询会出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆