Try this one:
What we're doing here is using a couple of CTE's to get the PATIENTID's for each patient who has the the procedures in question performed. We then start with all records in VISITINFO and inner join those with the two CTE's. Because an INNER JOIN requires that matching information exis...
Try this one:
I know it's a temporary table, I thought the OP had put it there just so we could test it without creating permanent tables. Also, they did say: "I am interested in using a multi-select drop down on an application interface and am looking to understand how to handle this...
Instead of using recursive cte you may use multiple cte to create your expression. Since sql already introduced this string_split function to convert your row cell into rows on particular delimeter, this will make our work lot easier. First we convert each cell value into individual rows. ...
theUPDATE/INSERT/DELETEetc). You can't use the same CTE in multiple statement, because CTE is...
Can't connect the sql server instance with host name from out side of the server ? can't connect to my server Can't enable Service Broker Can't KILL SessionID Can't start SQL Server Agent service? can/does sql decide to use multiple indexes on the same table reference in a query?
With the temporary tables approach you need to have multiple steps in your process, first to create the temporary table, then to populate the temporary table, then to select data from the temporary table and lastly cleanup of the temporary table. ...
Best way to delete 311 million records from SQL Server 2017 Best way to Delete million records from billion records table Best way to Delete the Data Best way to force materialize a CTE? Best way to reference calculated fields in a query Best way to update date to default value if = 1900...
Here is our second query that returns the list of customers that are either in the same level of the hierarchy or below based on the level of our user role: ; WITH customer_cte AS ( SELECT p.* FROM dbo.CustomerHierarchy c JOIN dbo.CustomerHierarchy p ...