Solved

How do I convert this SQL Statement from SQL Server?

Posted on 2008-10-09
3
2,387 Views
Last Modified: 2012-06-21
I am trying to convert the follow block of SQL from SQL Server to Teradata.

When compiling the code in Teradata, I get the following error:
3654:  Corresponding select-list expressions are incompatible.

How can I edit this code in order for it to compile properly?  Thank you!
select	EXTRACT(year from sold_date) ,
	EXTRACT(month from sold_date) ,
	EXTRACT(year from sold_date)*100+EXTRACT(month from sold_date), 
	ca.loan_num,
	sold_date,
	NULL,
	NULL
from	cmrmkt cr,
	cmacct ca
where	sold_date >= '2007-08-01' 
and	cr.receivable_id = ca.receivable_id
and	ca.loan_num not in (select loan_num from lcnam)
UNION
select	EXTRACT(year from sold_date) ,
	EXTRACT(month from sold_date) ,
	EXTRACT(year from sold_date)*100+EXTRACT(month from sold_date), 
	ca.loan_num,
	sold_date,
	lcm.charge_off_date,
	lcm.charge_off_flag
from 	cmrmkt cr,
	cmacct ca,
	lcnam lcm
where 	sold_date >= '2007-08-01'
and 	cr.receivable_id = ca.receivable_id
and 	ca.loan_num = lcm.loan_num;

Open in new window

0
Comment
Question by:SpeedsterZ28
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Expert Comment

by:Cedric_D
ID: 22682422
try replace two UNION parts...
0
 

Accepted Solution

by:
SpeedsterZ28 earned 0 total points
ID: 22682539
Do you mean get rid of the UNION and just do two INSERT INTO statements for each SELECT statement?
0
 
LVL 7

Expert Comment

by:Cedric_D
ID: 22755149
I mean, try switch these two parts each other, to allow server to know type of last two columns.

To solve this definitely, make explicit cast for all columns of both unions, to desired datatypes.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question