This seems very basic, but I haven't been able to find an example that works for me, so I'd appreciate any advice.
I have a SQL Server function that determines various dates based on our fiscal year and today's date, and returns one row which looks like...
<row LastDayPrevMonth="2015-04-30T00:00:00" LastDayPrevMonthLY="2014-04-30T00:00:00" ... />
In the stored proc which calls that function, I've done...
DECLARE @X XML
SET @X = dbo.GetFiscalYearDates()
...but then I can't seem to extract the value of LastDayPrevMonth.
I've tried dozens of variations of this:
SELECT ROW.ITEM.VALUE('LastDayPrevMonth', 'VARCHAR(30)')[1] AS Foo FROM @x.nodes('row/item') ... sometimes with an "AS Bar" at the end...
That particular syntax gives the error "incorrect syntax near the keywork 'as'", but any tweaks I do don't help.
Thanks for your assistance, dudes!