Hello, quick question,
I'm using SQL Server 2005.
Let's say I have a table (Customers) with the following field:
and I have a stored procedure that has 2 parameters.
and I have the following query syntax in my SP:
City = @SearchVal
Order by City
Is there a way I can use @MyField in both the WHERE and the Order By clauses like:
@MyField = @SearchVal
Order by @MyField
This way, I would have the option to search all of my fields without having to state it in the SP. I'd just pass the search value and the name of the field I want to search and sort by.
Do I have to declare @MyField as SYSNAME in order to make this work?