Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi,I am trying to create a view based on the following select statement:SELECT [CONTACT HISTORY CONTACTID], [HISTORY End Date], [HISTORY Details]FROM dbo.VRP_CONTACT_HISTORY AS cust_historyWHERE (([HISTORY Regarding] = 'Field Progress changed') or ([HISTORY Regarding] = 'Field Changed') or ([HISTORY Regarding] = 'Field changed'))AND ([HISTORY Details] LIKE '%to "Current client"')However when it runs, it gives me the following error:Conversion failed when converting from a character string to uniqueidentifier.I'm assuming the problem is related to the CONTACTID statement, but am unsure how to resolve it. I need to select the Contactid column to be able to perform a join with a table for a report that i am doing. Could someone suggest a workaround. Thanks
raky
Aged Yak Warrior
767 Posts
Posted - 2009-01-16 : 04:52:18
can you post the table structure ??
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts
Posted - 2009-01-16 : 04:54:48
whats the datatype for [CONTACT HISTORY CONTACTID], [HISTORY End Date], [HISTORY Details]?
hummy
Starting Member
32 Posts
Posted - 2009-01-16 : 04:55:57
ahh...looks like VRP_CONTACT_HISTORY is actually a view and not a table like i had thought. Could that be the problem
ra.shinde
Posting Yak Master
103 Posts
Posted - 2009-01-16 : 04:58:04
quote:Originally posted by raky can you post the table structure ??
Have yo got the answer?Rahul Shinde
raky
Aged Yak Warrior
767 Posts
Posted - 2009-01-16 : 04:59:02
try thisSELECT [CONTACT HISTORY CONTACTID], [HISTORY End Date], [HISTORY Details] AS cust_history FROM dbo.VRP_CONTACT_HISTORYWHERE [HISTORY Regarding] IN ( 'Field Progress changed','Field Changed')AND [HISTORY Details] LIKE '%to "Current client"'
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts
Posted - 2009-01-16 : 04:59:43
Just guessing what your problem is,
SELECT [CONTACT HISTORY CONTACTID], [HISTORY End Date], [HISTORY Details]FROM dbo.VRP_CONTACT_HISTORY AS cust_historyWHERE convert(varchar(50),[HISTORY Regarding]) in ('Field Progress changed','Field Changed')AND convert(varchar(2000),[HISTORY Details]) LIKE '%to "Current client"'