joebickley
Programmer
Hi, im trying the following in a stored proc
Select * from tablex
order by coalesce(@sortfield, referencenumber)
I want it to sort by a field that i pass into it, if it is not provided i want to use the reference number but it doesnt work. I cant build up the SQL text and execute it as i have other stuff going on that makes that impracticle. If i remove the coalesce bit and just put the @sortfield again it doent work
Any ideas?
Select * from tablex
order by coalesce(@sortfield, referencenumber)
I want it to sort by a field that i pass into it, if it is not provided i want to use the reference number but it doesnt work. I cant build up the SQL text and execute it as i have other stuff going on that makes that impracticle. If i remove the coalesce bit and just put the @sortfield again it doent work
Any ideas?