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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL Problem

Author  Topic 

hummy
Starting Member

32 Posts

Posted - 2009-01-16 : 04:47:00
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_history
WHERE (([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 ??
Go to Top of Page

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]?
Go to Top of Page

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
Go to Top of Page

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
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2009-01-16 : 04:59:02
try this

SELECT [CONTACT HISTORY CONTACTID], [HISTORY End Date], [HISTORY Details] AS cust_history
FROM dbo.VRP_CONTACT_HISTORY
WHERE [HISTORY Regarding] IN ( 'Field Progress changed','Field Changed')
AND [HISTORY Details] LIKE '%to "Current client"'
Go to Top of Page

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_history
WHERE convert(varchar(50),[HISTORY Regarding]) in ('Field Progress changed','Field Changed')
AND convert(varchar(2000),[HISTORY Details]) LIKE '%to "Current client"'
Go to Top of Page
   

- Advertisement -