Skip to content

Tag: sql-server

Build change history from table with historical row values

I have table that is storing historical values for data in other table: Now I need to generate from such table “change log” which will show what was old value, new value and when update occur: Unfortunately, I can’t change structure of the existing table and can’t put old value there, …

Query to replace ID with Name within the same table?

Can anyone help me figure out this SQL Query? I have the following table: I want the new table to look like this: So essentially I want to replace the third column from “ManagerId” to “Manager Name,” where all information is retrieved in the same table. Can anyone help me with the quer…

Sql Grouping insight Xml

I need to get different row data to 1 row based with id and need to group by its status. I tried in several ways and finally found a solution using xml, but when I use xml I don’t get the output I want. This is a sample code I used to try the logic. returned output: expected output: Answer

Update duplicate data with same unique-identifier

I have the following table in my database: So I want to generate Unique-identifier and Update the UniqueID column as shown below: If values of UniqueID are the same, then they must have the same Uniqueidentifier. I have tried to write a CTE as below: But am not getting what am looking for. Very knew to the wo…