开发者

C# - SQL WITH clause

Just fishing for ideas-

I have a SQL statement that I need to parse in C#. It is formatted basically as follows -

    WITH TableX as (

    -- something else could be here..
    select field1, field2, .. fieldX
    from mytable
    -- something else could be here..

    )

    -- something else could be here..
    select /*THESE FIELDS ARE BEING REPLACED*/ TableX.field1, TableX.field2, .. TableX.fieldX
    from TableX
    -- something else could be here.. ie, more joins, selecting from subqueries. Basically another select could exist here.

Any ideas on how 开发者_开发知识库to replace "TableX.field1, TableX.field2, .. TableX.fieldX" with another group of field guaranteed to be in the result set?


you could use a complete sql parser to build a parse tree, then replace the items selectively from there.

non-trivial task.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜