Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to merge three values in one column in select query, except getdate functionquery working fine but when i write getdate() it gives error. "Conversion failed when converting the varchar value 'FA/118,' to data type int." following is my query which is raising the error

SQL
select top 1 ([Casetype] +'/'+ CaseNo +','+ YEAR(GETDATE()) )as CaseNo from tbl_RecordRequisition where Casetype='FA' order by id desc


please help
Posted

select top 1 ([Casetype] +'/'+ convert(varchar(50),CaseNo) +','+ convert(varchar(50),YEAR(GETDATE())) )as CaseNo from tbl_RecordRequisition where Casetype='FA' order by id desc
 
Share this answer
 
select top 1 (isnull(Casetype,'') +'/'+ convert(varchar(50),isnull(CaseNo,'')) +','+ convert(varchar(50),YEAR(GETDATE())) )as CaseNo from tbl_RecordRequisition where Casetype='FA' order by id desc
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900