Skip to content
Advertisement

Tag: tsql

UPDATE ACROSS JOIN SYNTAX

I am trying to get an update statement to function how I need. I’ve tried the following with INNER / OUTER LEFT / RIGHT JOINS. I continue to have records that are not updated in the usertype2 table despite having usertype3 child values. Am I going about this the right way? Usertype2 and Usertype3 will always have a mat_id parent

Logic for backward updation based on parent value

I have below tables with data as below Table_Cell Table_column Table_row I need to update SwitchCol in Table_column and Switchrow in Table_row Logic is If for an column_id in Table_column, all the combination with row_id in Table_row,present in table Table_Cell is 1, then make the SwitchCol =1 for that column_id Similary, for an id in Table_row, all the combination of

Best practice for verifying correctness of data in MS SQL

We have multiple tables with different data (for example masses, heights, widths, …) that needs to be verified by employees. To keep track of already verified data, we are thinking about designing a following table: This table links the different product id’s, tables and columns that will be verified, for example: While creating foreign keys, we were able to link

Alternate approach to WITH CTE and large UNION query

I’d like to rework a script I’ve been given. The way it currently works is via a WITH CTE using a large number of UNIONs. Current setup We’re taking one record from a source table, inserting it into a destination table once with [Name] A then inserting it again with [Name] B. Essentially creating multiple rows in the destination, albeit

Advertisement