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 |
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 datePlease advise.Thank you.select PK='AID',FieldName='p_date',tblname, OldValue=p_date, NewValue=0 from tempwhere tblName='tbl' --return no value union all select PK='AID',FieldName='p_date',tblname='-',OldValue=0, NewValue=p_date from tempwhere 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.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
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 NewValueFROM dbo.TempWHERE tblName = 'tbl'UNION ALL SELECT 'AID' AS PK, 'p_date' AS FieldName, '-' AS tblname, '19000101' AS OldValue, p_date AS NewValueFROM dbo.TempWHERE tblName = 'temp1'[/code] N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|
|
|