Originally posted by **cptb** August 3, 2022
Hi Bruce,
I am sorry for "always" throwing hard questions at you. This tool is wonderful and I have been using it since last year.
Just now, I met a complex query which contains a STUFF function, and inside the function, the first parameter is a SELECT statement to generate some texts. It looks like the below statement.
`select stuff
(
(select top 10 note from asset_note where note is not null order by note_id for XML path(''))
, 1
, 1
, 'Note: '
);`
My C# code looks like this:
```
string sql = @"select stuff((select top 10 note from asset_note where note is not null order by note_id for xml path('')), 1, 1 , 'Note: '); ";
var statements = TSQLStatementReader.ParseStatements(sql); // this method throws NULL ref exception
```
If the script is simple like this:
`SELECT STUFF('SQL Tutorial', 1, 3, 'HTML')`
It can be parsed successfully.
Could you please look at this issue to see if it is possible to embed SELECT inside the STUFF function?
It is valid SQL to use SELECT inside STUFF.
Regards
Paul
Discussed in https://github.com/bruce-dunwiddie/tsql-parser/discussions/107