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 2000 Forums
 SQL Server Development (2000)
 Problem with my Case statement.

Author  Topic 

mxfrail
Yak Posting Veteran

84 Posts

Posted - 2008-08-26 : 11:51:54
Here is my SQL -

SELECT tblInvoiceHdr.InvoiceDate AS [Date],
tblInvoiceHdr.ClientID, cast([TotalDue] as dec(12,2)) AS Amount,
[Tranaction] = case when tblInvoiceHdr.Invoicetype = 'ADJ' then 'REF#' + tblInvoiceHdr.InvoiceNO + ' - ' + 'Account Adjustment-' else
'REF#' + tblInvoiceHdr.InvoiceNO + ' - ' + 'Advertising Services Due: for Mailing: ' + [Description] end,
'INV' as Type
FROM tblInvoiceHdr
WHERE tblInvoiceHdr.Status<>'VOID'

I keep getting this error -

Syntax error converting the varchar value 'REF#' to a column of data type int.


'Ref#' is just text that I am trying to display with the values.

I tried putting in ( )'s etc but nothing seems to work. Any questions?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-26 : 11:58:06
convert to string before concat it
then 'REF#' + convert(varchar(10), tblInvoiceHdr.InvoiceNO)



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

mxfrail
Yak Posting Veteran

84 Posts

Posted - 2008-08-26 : 12:06:19
Perfect. thanks!
Go to Top of Page
   

- Advertisement -