I have a function that returns dates in a specific format
FormatDate(int PreviousMonths, int Format) returns varchar(100) – E.g. FormatDate(0,2) returns ‘June 2011’
But I’m having trouble aliasing the column properly.
A simple example that gives a syntax error is:
Select Foo as dbo.FormatDate(0,2) From FooTable
How can I alias a column with the result of a function?
Sorry, my question seems to be a bit unclear – here is some additional information:
Table named FooTable consisting of one column named Foo, with 3 rows of data containing 1, 2, 3.
Select Foo as dbo.FormatDate(0,2) From FooTable
Returns:
June 2011
1
2
3
Thanks,
Dustin
Almost there…
Select Foo = dbo.FormatDate(0,2) From FooTable
Or
Edit:
You can’t have dynamic column aliases, especially not per row
You can have the value sent out like this though: