I've got this dynamic t-sql:
declare @sql nvarchar(max)
set @sql =
N'
insert into #t
SELECT
row_number() over(order by getdate()) as RowNum,
d.value('''+@baseDateXpath+''', ''datetime'') as basedate,
pref.query(''.'') as XmlExtract
FROM
@content.nodes(''/*/*'') AS extract(pref)
CROSS APPLY
@content.nodes(''//*'') AS datey(d)
WHERE
pref.value(''.//*[1]'', ''nvarchar(50)'') IS NOT NULL'
exec sp_executesql @sql,
N'@content xml',
@anXmlContentStr
And it doesn't work because (I think) the escaping of the forward slashes is being mis-interpreted.
How do I write this string so that it will execute properly?