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 2005 Forums
 Transact-SQL (2005)
 Unsupported Data Type from 2008 to 2005

Author  Topic 

mike13
Posting Yak Master

219 Posts

Posted - 2012-11-14 : 07:16:13
Got it to work on 2008 but i get <Unsupported Data Type> on 2005, any idea how to fix it

SELECT TOP (100) PERCENT managername, '(' + RTRIM(CAST(Aemails AS char)) + ') ' + shopname AS amountemails
FROM (SELECT managername, shopname,
(SELECT COUNT(*) AS msg
FROM dbo.T_Customer_Mailbox AS A
WHERE (datereply IS NULL) AND (status = 1) AND (ToUser = B.managername)) AS Aemails
FROM dbo.T_SYS_ShopSystem AS B) AS T
WHERE (Aemails > 0)
ORDER BY shopname

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-11-14 : 08:05:32
For everyone who is willing to help - here is a formatted query:
SELECT TOP (100) PERCENT 
managername,
'(' + RTRIM(CAST(Aemails AS char)) + ') ' + shopname AS amountemails
FROM
(
SELECT
managername,
shopname,
(SELECT COUNT(*) AS msg FROM dbo.T_Customer_Mailbox AS A WHERE (datereply IS NULL) AND (status = 1) AND (ToUser = B.managername)) AS Aemails
FROM dbo.T_SYS_ShopSystem AS B
) AS T
WHERE (Aemails > 0)
ORDER BY shopname



Too old to Rock'n'Roll too young to die.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-11-14 : 08:51:59
My guess is that this is a view and it doesn't like the CAST(Aemails AS char) without a length being specified. Since Aemails is an int, varchar(10) would be more appropriate.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

mike13
Posting Yak Master

219 Posts

Posted - 2012-11-14 : 09:48:29
Thanks a lot that solved the issue
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-11-14 : 09:58:39
You're welcome.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -