Skip to content

Tag: sql-server

Trigger to create or update records in another table

Edit: This question is mostly solved. What I am still trying to do might require a different approach. I am adding a trigger to a legacy database table, in order to automatically create new records for a related table. This is not homework. Here is my DB Fiddle on SQL Server 2017. https://dbfiddle.uk/?rdbms=s…

Check if procedure exists in any database SQL Server

I’d like to know if there is any way to search for a procedure in all the databases of a server (there are only SQL Server databases on that server). So far I’ve only found how to find a stored procedure in a certain database with Object_id(), but it would take too long for me to manually search e…

SQL Server: How to flatten nested arrays by merging values using

I have 10000 jsons with different ids each has 10000 names. How to flatten nested arrays by merging values usin SQL Server? Jsons can be read in any language, I’m looking for any SQL dialect that can transform the data as I’m using spark connectors. I use many SQL dialects including not limiting S…

How to group by two columns in different CASE clauses

I have a query that’s giving me the results I want, but for each item with a given ID_UNIDAD_EXPERIMENTAL there are two rows, one with column “Alt” with a value and column “Dap” with null, and the other one with “Alt” null and “Dap” with a value. My questi…