I created a linked server in SSMS so that I could run reports on a SpiceWorks SQLite database.  there are a few quirks in the whole system.These simple queries are becoming some of the most expensive queries on my reporting SQL Server, I kind of know why, is there a way that I can do this differently?The CodeI have two queries.TimeToCloseByAssignee SELECT     id AS ticketNum    , Summary    , Assignee    , closed_at    , created_at    , ROUND((DATEDIFF(Hour, created_at, closed_at))/24. , 2) AS DaysOpenFROM OPENQUERY(SPICEWORKS,'    SELECT tickets.id         , users.email as Assignee        , substr(tickets . summary, 1,100) AS Summary        , tickets.closed_at        , tickets.created_at    FROM tickets        INNER JOIN users ON tickets.assigned_to = users.idWHERE status=''closed''        AND         master_ticket_id IS NULL;')GetCreatorByTicketIDSELECT * FROM OPENQUERY(SPICEWORKS, '    SELECT users.email        , tickets.id    FROM tickets        INNER JOIN users ON tickets.created_by = users.id')WHERE id = @TicketIDI am using SSRS to handle the nice presentation of the data.the problem with this, is that I can't give the underlying SQLite query boundaries from SSRS Parameters, it just doesn't like it. There are some questions on StackOverflow with answers and ways to do it, but this was the only way that I could make it work the way I wanted it to.   perhaps I wasn't interpreting the answers correctly.  either way I don't think it would have been clean and straightforward anyway.Any thoughts? 
Another way to run reports on a SpiceWorks SQLite database using a linked server in SSMS?
sql;sql server;sqlite
I was able to remove the second query and merge it with the first one like this, I don't know why I didn't try it like this to begin with, probably because I wanted to tread lightly on this shaky bridge.   I still don't have a solid way of passing variables to the OPENQUERY, but that is a question perhaps for StackOverflow when I have more time to work on this project.Code:SELECT     id AS ticketNum    , Summary    , Assignee    , closed_at    , created_at    , Round((DATEDIFF(HOUR,created_at, closed_at))/24. , 2) AS DaysOpen    , CreatorFROM OPENQUERY(SPICEWORKS, '    SELECT tickets.id        , users.email AS Assignee        , substr(tickets . summary, 1,100) AS Summary        , tickets.closed_at        , tickets.created_at        , table2.email AS Creator    FROM        tickets        INNER JOIN users ON tickets.assigned_to = users.id        INNER JOIN users AS table2 ON tickets.created_by = table2.id     WHERE tickets.status = ''closed'' AND tickets.master_ticket_id IS NULL;')what I did here was turn the other query into a separate join to the users table but joined the aliased table on another field in the tickets table.  this way I can get both the creator and the assigned user (Assignee) from this single query.  getting rid of the second Query  reduced the amount of queries to the SQLite database to just one,  the other way was executing the second query an outrageous amount of times because the second query would run once for every row in the first query,  THIS IS HORRIBLY INEFFICIENT, do not do this unless you absolutely have to.I should have explained more,  the second query had to be a sub-report of the first one in order for it to work the way I wanted it to.  I didn't think I could alias tables in a query run this way, I wasn't fully qualifying the names of all my columns once I put an alias in, and that is why I didn't do that the first go round, but now I know that I can do this on SQLite as long as I fully qualify all the columns I select in the query run on the SQLite database 