Solved

<Unsupported Data Type> (Query Problem)

Posted on 2009-06-28
4
752 Views
Last Modified: 2012-05-07
Hi,

I have query below.

The problem is at column "AccNo", it shows <Unsupported Data Type> at all the rows.

What's wrong with my code?

Thank you.
WITH JobCTE AS (SELECT     A.AccNo, COALESCE (SUM(A.SaldoAwalDbt), 0) AS SaldoAwalDbt, COALESCE (SUM(A.SaldoAwalKrd), 0) AS SaldoAwalKrd, 

                                                              COALESCE (SUM(A.Debet01), 0) AS MutasiDebet, COALESCE (SUM(A.Kredit01), 0) AS MutasiKredit, B.GlobalAcc

                                       FROM         THLEDGER2008 AS A LEFT OUTER JOIN

                                                              TMGLACCNO AS B ON A.AccNo = B.AccNo LEFT OUTER JOIN

                                                              TMGLTYPE AS C ON C.GLTypeCode = B.GLTypeCode

                                       WHERE     (B.Global <> 'Y') AND (C.Tipe = 'N') AND (B.GLTypeCode = 'AS')

                                       GROUP BY A.AccNo, B.GlobalAcc)

    SELECT     A.GlobalAcc AS AccNo, B.Name, SUM(A.SaldoAwalDbt) AS SaldoAwalDbt, SUM(A.SaldoAwalKrd) AS SaldoAwalKrd, SUM(A.MutasiDebet) 

                            AS MutasiDebet, SUM(A.MutasiKredit) AS MutasiKredit, B.GlobalAcc, C.Saldo

     FROM         JobCTE AS A LEFT OUTER JOIN

                            TMGLACCNO AS B ON A.GlobalAcc = B.AccNo LEFT OUTER JOIN

                            TMGLTYPE AS C ON C.GLTypeCode = B.GLTypeCode

     GROUP BY A.GlobalAcc, B.Name, B.GlobalAcc, C.Saldo

Open in new window

0
Comment
Question by:emi_sastra
  • 2
  • 2
4 Comments
 
LVL 17

Expert Comment

by:pssandhu
ID: 24730708
My first guess would be that the data types for columns GlobalAcc and AccNo are different. Can you and check and confirm if this is the case?
To avoid this you can use CAST() function to cast the other column to the correct data type. If your GlobalAcc is of type nvarchar and Accno as INT then we can cast AccNo to nvarchar. Something like this (see you join statement in the second query):



WITH JobCTE AS (SELECT     A.AccNo, COALESCE (SUM(A.SaldoAwalDbt), 0) AS SaldoAwalDbt, COALESCE (SUM(A.SaldoAwalKrd), 0) AS SaldoAwalKrd, 

                                                              COALESCE (SUM(A.Debet01), 0) AS MutasiDebet, COALESCE (SUM(A.Kredit01), 0) AS MutasiKredit, B.GlobalAcc

                                       FROM         THLEDGER2008 AS A LEFT OUTER JOIN

                                                              TMGLACCNO AS B ON A.AccNo = B.AccNo LEFT OUTER JOIN

                                                              TMGLTYPE AS C ON C.GLTypeCode = B.GLTypeCode

                                       WHERE     (B.Global <> 'Y') AND (C.Tipe = 'N') AND (B.GLTypeCode = 'AS')

                                       GROUP BY A.AccNo, B.GlobalAcc)
 

    SELECT     A.GlobalAcc AS AccNo, B.Name, SUM(A.SaldoAwalDbt) AS SaldoAwalDbt, SUM(A.SaldoAwalKrd) AS SaldoAwalKrd, SUM(A.MutasiDebet) 

                            AS MutasiDebet, SUM(A.MutasiKredit) AS MutasiKredit, B.GlobalAcc, C.Saldo

     FROM         JobCTE AS A LEFT OUTER JOIN

                            TMGLACCNO AS B ON A.GlobalAcc = Cast(B.AccNo as nvarchar(50)) LEFT OUTER JOIN

                            TMGLTYPE AS C ON C.GLTypeCode = B.GLTypeCode

     GROUP BY A.GlobalAcc, B.Name, B.GlobalAcc, C.Saldo

Open in new window

0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24730744
Hi pssandhu,

The are the same type.

AccNo      char(11)       
Name      char(70)       
Global      char(1)       
GlobalAcc      char(11)       
GLTypeCode      char(2)       
Propotional      char(1)       
CrtId      char(10)       
CrtDate      datetime       
UpdId      char(10)       
UpdDate      datetime       

Weird, some times problem, sometimes not.

Thank you.
0
 
LVL 17

Accepted Solution

by:
pssandhu earned 500 total points
ID: 24730789
Although this might not make a difference but may be some null values are throwing off your query. Try using ISNULL to default the value from Null to something else. Something like this:
ON ISNULL(A.GlobalAcc,'00000000000') = ISNULL(B.AccNo, '00000000000')
Also, you are not by any chance using Visual Database Tools and working with data in "Result Pane". I found some reference regarding that:
http://msdn.microsoft.com/en-us/library/ms172022(VS.80).aspx
If so, check out the discussion under the last  heading "What cannot be represented Full".
Hope this helps.
P.
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24731028
Hi pssandhu,

Thank you very much for the information.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now