Skip to content

Tag: sql-server

Evaluate Multiple conditions for same row

I have to compare 2 different sources and identify all the mismatches for all IDs Source_excel table Source_dw table Expected result I have tried the below query but it is giving only one mismatch. Actual output I understand that case expression will only check the first satisfying condition. Is there any oth…

Stored procedure to unpivot

I have a table with these columns: Where fields from 01 to 50 are dates. I need to have a table like this: Where title code should be the column name from 01 to 50, data should be the value of that column in mytable I did this stored procedure by looking in older questions: but I’m getting a syntax

Combine data of double rows as output

I have an example table with Ids and Names, I would like to get a new table with unique Ids and the names of one column combined (grouped by ID). My data looks like this (SQL Server 2017 & 2019 – SSMS): My goal is to get the following output with a qry: Does anybody has a tip/suggestion how to

SQL query to get rows contains value of another query

I have 2 tables transaction and query. Transaction table have unique tid and the query table has tid_(subtransactionid). I want to get the list of all subtransactions by using tid. I tried this Answer You can join the tables and use the operator LIKE in the ON clause: If your database does not support the fun…