Solved

<Unsupported Data Type> (Query Problem)

Posted on 2009-06-28
4
753 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Addition to SQL for dynamic fields 6 38
T-SQL Query to include null values 3 30
SSRS 2012 r2 - Parm Drop Down has Date/Time 12 33
sql server computed columns 11 31
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 article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

809 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