• Siten0308 - Monday, March 20, 2017 4:21 PM

    Hey guys,

    need your briliant minds, sadly i dont have one 🙁 and sorry for the confused title.

    ok i have a select statement like:

    select OrderID, customer name, blah blah
    from dbo.orders

    however i am using this select statement in BIML, but dont let that throw anyone off, i am trying to say:

    select *
    from dbo.orders
    where orders in
    (
    select name
    from sys.tables
    where name like 'orders'
    )

    therefore it will complete the select statement, however if it wasnt an order table, then skip the select statement, i am really sorry if i am not explaining it right, but that is what i can think on top of my head how i can accomplish my task that BIML requires.

    what the main purpose is to dynamically do select statements for only certain tables in a database, if it meets my criteria, then do the select statement, if not, skip it.... is this possible?

    thanks in advance

    Dynamically, based on what?

    Do you want a loop which iterates round all tables containing the word 'Orders' and selects all rows from them?

    Like 'Orders' is the same as = 'Orders', because you have not included any wildcards.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.