Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
bendertez
Yak Posting Veteran
94 Posts |
Posted - 2010-11-16 : 09:40:51
|
HiI'm trying to join a table from another database. In the first database the primary key is in the following format: {12345678}In the table that i'm trying to join the primary key is in the format of 12345678What I want to do is join the two table together but I know I will need to remove the { } within the field to be able to join them.I thought it would be quite straight forward using the following code :SELECTc.cust_name, REPLACE(REPLACE(c.customer_id, '{', ''), '}', '') as CRMS_ID,b.emailaddress1FROM Customer CLEFT Join CRMS.dbo.Contacts b ON REPLACE(REPLACE(c.customer_id, '{', ''), '}', '')=b.accountidWhen I run this code I get the following error:Conversion failed when converting from a character string to uniqueidentifier.Does anyone know if this can actually be done this way?The result of the replace function is what I want but it doesn't want to join together.Any help will be appreciated.ThanksDave |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-11-16 : 09:50:41
|
Please give the DDL of the involved tables so that we have not guess about. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
bendertez
Yak Posting Veteran
94 Posts |
Posted - 2010-11-16 : 10:24:12
|
Hi WebFredSorry what do you mean by DDL?The only link I can see is the DBS.dbo.customer_ID to CRMS.dbo.Contacts.accountid (but withou the brackets {} I mentioned above). ThanksDave |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-11-16 : 10:43:31
|
DDL = DataDefinitionLanguageThat means if we can see the CREATE TABLE statement(s) then we are able to find a solution. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|