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 2008 Forums
 Transact-SQL (2008)
 Operand type clash: int is incompatible with date

Author  Topic 

micnie_2020
Posting Yak Master

232 Posts

Posted - 2012-03-02 : 07:48:04
Dear All,

I get error:
Operand type clash: int is incompatible with date

Please advise.

Thank you.

select
PK='AID',FieldName='p_date',tblname, OldValue=p_date, NewValue=0 from temp
where tblName='tbl' --return no value
union all
select PK='AID',FieldName='p_date',tblname='-',OldValue=0, NewValue=p_date
from temp
where tblName='temp1' --return no value

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2012-03-02 : 09:27:51
You are setting OldValue to p_date in one query, and 0 in the next. Each column needs to be the same data type in both queries. Same for NewValue.

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-03-02 : 10:06:16
[code]SELECT 'AID' AS PK,
'p_date' AS FieldName,
tblname,
p_date AS OldValue,
'19000101' AS NewValue
FROM dbo.Temp
WHERE tblName = 'tbl'

UNION ALL

SELECT 'AID' AS PK,
'p_date' AS FieldName,
'-' AS tblname,
'19000101' AS OldValue,
p_date AS NewValue
FROM dbo.Temp
WHERE tblName = 'temp1'[/code]


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -