0

My query fails with the following error: Conversion failed when converting from a character string to uniqueidentifier.

My query in 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

The error is caused by reg_key column in the ev_registrant table. The reg_key column is ROWGUIDCOL(uniqueidentifier)

How can I pull the record? Thank you.

  • did u remove quotes in reg_key where clause and tried ? – Ven Nov 07 '17 at 16:32
  • I assume you also missed a quote on the last line? and you didn't use a cast function from what I can tell – S3S Nov 07 '17 at 16:36
  • Oh. I just missed the single quote when I copied it. I didn't use the CAST function. That's what I would like to know, how can I use it so it won't give the the error. –  Nov 07 '17 at 17:07

0 Answers0