I wrote a function that will be passed 1 string parameter. Inside that function it is supposed to get that string as you can see but its not working because parameter I transfer is string. The receiver of parameter suppose to get column name if I write column name as its format it works fine but I need to get passed.
This is the string I pass:
[Where], [University], [BeginDate], [GraduateDate], [Major]
Now this is function
DROP FUNCTION NewTable
GO
CREATE FUNCTION NewTable
(@PassParameter NVARCHAR(MAX))
RETURNS TABLE
AS
RETURN
SELECT *
FROM
(SELECT O.RowIndex, O.OptionValue, T.TypeValue
FROM Options O
LEFT OUTER JOIN Types T ON T.TypeID = O.TypeID
GROUP BY O.RowIndex, O.OptionValue, T.TypeValue) d
PIVOT
(
MAX(OptionValue)
FOR [TypeValue] IN (@PassParameter) <-- this is tricky part this will not work but I put this [Where], [University], [BeginDate], [GraduateDate], [Major] this is gonna work
) PIV
GO
Also I can't use a stored procedure because using a function is my requirement.