Microsoft
Software
Hardware
Network
Question : Join between LONGVARBINARY and CHAR
Hi,
I am attempting a join between two tables:
JOIN table2.dbo.USERS
ON table1.dbo.CMS_USERDATA.DA
TA_VALUE = table2.dbo.USERS.UserGUID
The problem is that the DATA_VALUE column is of type LONGVARBINARY and UserGUID is of type CHAR. This results in the following error:
"Error code 306, SQL state S0001: The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator."
I attempted to use a LIKE operator instead of the equals operator but I just get the following error:
"Error code 403, SQL state S0002: Invalid operator for data type. Operator equals LIKE, type equals uniqueidentifier."
The contents of DATA_VALUE will always be a string of characters and in theory should match the characters in UserGUID. If DATA_VALUE could be converted to CHAR then it should be able to work but I have no idea how to do that for the following SQL query:
SELECT *
FROM table1.dbo.CMS_USERS
INNER JOIN table1.dbo.CMS_USERDATA
ON table1.dbo.CMS_USERS.USER_
ID = table1.dbo.CMS_USERDATA.US
ER_ID
JOIN table2.dbo.USERS
ON table1.dbo.CMS_USERDATA.DA
TA_VALUE = table2.dbo.USERS.UserGUID
WHERE table1.dbo.CMS_USERDATA.DA
TA_KEY = 'UserGUID'
Any idea on how I can achieve this JOIN?
Thanks
Answer : Join between LONGVARBINARY and CHAR
change
ON table1.dbo.CMS_USERDATA.DA
TA_VALUE = table2.dbo.USERS.UserGUID
to
ON convert(nvarchar(4000), table1.dbo.CMS_USERDATA.DA
TA_VALUE) = convert(nvarchar(4000), table2.dbo.USERS.UserGUID)
Just expanding on what conagraman said.
Random Solutions
ODBC connect to ORACLE 11G using Redhat Linux 5.4
Getting round-robin load balancing working with vSphere 4.0 cluster on EqualLogic PS4000X
do you need sysprep with Symantec Ghost Solution Suite 2.5?
Use different HTTP Redirects on multiple virtual directories in IIS 7.5
Imail Mail Server blocked. Cant see why
Give public access to our wireless network?
Roaming profiles and DFS replication
Congratulations to new Excel Genius: teylyn
Auto Send Excel as Email Attachment
Can't Figure Out How to Turn Off PHP Display Errors