Click here to Skip to main content
16,018,805 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to know how to get invoice number from below query

SET @InvoiceNo='Final/' + (CASE WHEN @month <= 3 THEN  CAST((@year-1) AS VARCHAR) ELSE CAST(@year AS VARCHAR) END) +'-' + (CASE WHEN @month <= 3 THEN  CAST(((@year)%2000) AS VARCHAR) ELSE CAST(((@year+1)%2000) AS VARCHAR) END)+'/'+ CONVERT(VARCHAR(10),@CurrentNo)
print @InvoiceNo



i facing a problem with this query i am getting null value, pls someone help...

What I have tried:

how to get invoice number
Posted
Updated 14-Mar-17 23:28pm
Comments
CHill60 15-Mar-17 6:04am    
What are the values of @month, @year and @CurrentNo?

1 solution

Get it where? It's in the @InvoiceNo variable so if you want to use it another query

select @InvoiceNo as InvoiceNo, othefield FROM sometable


if you just want to return it as a result on its own

select @InvoiceNo as InvoiceNo
 
Share this answer
 
Comments
chander rani 15-Mar-17 5:34am    
i want to know the meaning of this query, like this query is generating a invoice number but i am getting null value, Why??
F-ES Sitecore 15-Mar-17 7:21am    
We don't have access to your data so it's impossible to say. Break the function down into it's individual parts and try and work out where the null is coming from.
chander rani 15-Mar-17 8:14am    
yes i am doing thanks...

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