如何在数据转换失败时使用强制转换功能

时间:2017-11-07 16:30:24

标签: sql sql-server-2012 data-conversion

我的查询失败,出现以下错误:从字符串转换为uniqueidentifier时转换失败。

我在SQL Server 2012中的查询:

SELECT DISTINCT
cst_recno as [Member ID],
reg_key,
ind_first_name as 'First name',
ind_last_name as 'Last name',
cst_ixo_title_dn as [Title],
cst_org_name_dn as [Organization],
cst_eml_address_dn as [Email],
cst_phn_number_complete_dn as [Phone],
evt_code as 'Event Code',
adr_line1 as 'Address',
adr_city as 'City',
adr_post_code as 'Zip Code',
adr_state as 'State',
adr_country as 'Country',
Membership.mem_member_type as [Member Type],
chp_name as 'DC/NC',
reg_registration_date as 'Registration Date'
FROM 
ev_registrant 
JOIN co_customer ON reg_cst_key=cst_key and cst_delete_flag=0
and reg_delete_flag=0 
JOIN ev_event ON reg_evt_key=evt_key 
LEFT JOIN co_individual  ON reg_cst_key=ind_cst_key 
LEFT JOIN co_customer_x_address  ON cxa_key=reg_cxa_key 
LEFT JOIN co_address  ON adr_key=cxa_adr_key 
LEFT JOIN vw_client_uli_member_type Membership ON cst_key=mem_cst_key 
LEFT JOIN co_customer_x_customer ON cxc_cst_key_1 =cst_key and (cxc_end_date is null or datediff(dd,getdate(),cxc_end_date) >=0) and cxc_rlt_code='chapter member' 
LEFT JOIN co_chapter ON cxc_cst_key_2=chp_cst_key 
WHERE reg_cancel_date Is Null AND reg_delete_flag = 0 AND evt_code = N'FALL2017'and reg_key ='bstg_autogen_1503511093276_27787953

错误是由ev_registrant表中的reg_key列引起的。 reg_key列是ROWGUIDCOL(uniqueidentifier)

我该怎么拉记录? 谢谢。

0 个答案:

没有答案